cocoaTouch/GameSetup.m
author sheepluva
Thu, 17 Jun 2010 13:56:30 +0200
changeset 3511 76e2d79b91b1
parent 3495 a6b4f351d400
child 3513 f589230fa21b
permissions -rw-r--r--
some pt_BR translation changes by arrom
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
     1
//
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
     2
//  gameSetup.m
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
     3
//  hwengine
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
     4
//
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
     5
//  Created by Vittorio on 10/01/10.
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
     7
//
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
     8
3335
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3332
diff changeset
     9
#include <sys/types.h>
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3332
diff changeset
    10
#include <sys/sysctl.h>
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3332
diff changeset
    11
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    12
#import "GameSetup.h"
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    13
#import "SDL_uikitappdelegate.h"
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    14
#import "SDL_net.h"
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    15
#import "PascalImports.h"
3335
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3332
diff changeset
    16
#import "CommodityFunctions.h"
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    17
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    18
#define BUFFER_SIZE 256
3221
3e6586c1ab4f koda's changelog turn
koda
parents: 3199
diff changeset
    19
#define debug(format, ...) CFShow([NSString stringWithFormat:format, ## __VA_ARGS__]);
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    20
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    21
@implementation GameSetup
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    22
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    23
@synthesize systemSettings, gameConfig;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    24
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    25
-(id) init {
3170
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    26
	if (self = [super init]) {
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    27
        ipcPort = randomPort();
3170
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    28
        
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
    29
        // should check they exist and throw and exection if not
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
    30
        NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    31
        self.systemSettings = dictSett;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    32
        [dictSett release];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    33
        
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    34
        NSDictionary *dictGame = [[NSDictionary alloc] initWithContentsOfFile:GAMECONFIG_FILE()];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    35
        self.gameConfig = dictGame;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    36
        [dictGame release];
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
    37
    } 
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
    38
    return self;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    39
}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    40
3221
3e6586c1ab4f koda's changelog turn
koda
parents: 3199
diff changeset
    41
-(NSString *)description {
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    42
    return [NSString stringWithFormat:@"ipcport: %d\nsockets: %d,%d\n teams: %@\n systemSettings: %@",ipcPort,sd,csd,gameConfig,systemSettings];
3221
3e6586c1ab4f koda's changelog turn
koda
parents: 3199
diff changeset
    43
}
3e6586c1ab4f koda's changelog turn
koda
parents: 3199
diff changeset
    44
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    45
-(void) dealloc {
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
    46
    [gameConfig release];
3029
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3021
diff changeset
    47
    [systemSettings release];
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    48
	[super dealloc];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    49
}
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    50
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    51
#pragma mark -
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    52
#pragma mark Thread/Network relevant code
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
    53
// select one of GameSetup method and execute it in a seprate thread
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    54
-(void) startThread: (NSString *) selector {
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    55
	SEL usage = NSSelectorFromString(selector);
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
    56
	[NSThread detachNewThreadSelector:usage toTarget:self withObject:nil];
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    57
}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    58
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
    59
// wrapper that computes the length of the message and then sends the command string
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    60
-(int) sendToEngine: (NSString *)string {
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    61
	uint8_t length = [string length];
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    62
	
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    63
	SDLNet_TCP_Send(csd, &length , 1);
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    64
	return SDLNet_TCP_Send(csd, [string UTF8String], length);
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    65
}
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    66
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    67
// unpacks team data from the selected team.plist to a sequence of engine commands
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    68
-(void) provideTeamData:(NSString *)teamName forHogs:(NSInteger) numberOfPlayingHogs withHealth:(NSInteger) initialHealth ofColor:(NSNumber *)teamColor {
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    69
    /*
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    70
     addteam <32charsMD5hash> <color> <team name>
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    71
     addhh <level> <health> <hedgehog name>
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    72
     <level> is 0 for human, 1-5 for bots (5 is the most stupid)
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    73
    */
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    74
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    75
    NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@", TEAMS_DIRECTORY(), teamName];
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
    76
    NSDictionary *teamData = [[NSDictionary alloc] initWithContentsOfFile:teamFile];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
    77
    [teamFile release];
3199
1a9938a27677 fixes to the mac build system
koda
parents: 3170
diff changeset
    78
    
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    79
    NSString *teamHashColorAndName = [[NSString alloc] initWithFormat:@"eaddteam %@ %@ %@", 
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
    80
                                      [teamData objectForKey:@"hash"], [teamColor stringValue], [teamData objectForKey:@"teamname"]];
3170
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    81
    [self sendToEngine: teamHashColorAndName];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    82
    [teamHashColorAndName release];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    83
    
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    84
    NSString *grave = [[NSString alloc] initWithFormat:@"egrave %@", [teamData objectForKey:@"grave"]];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    85
    [self sendToEngine: grave];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    86
    [grave release];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    87
    
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    88
    NSString *fort = [[NSString alloc] initWithFormat:@"efort %@", [teamData objectForKey:@"fort"]];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    89
    [self sendToEngine: fort];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    90
    [fort release];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    91
    
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    92
    NSString *voicepack = [[NSString alloc] initWithFormat:@"evoicepack %@", [teamData objectForKey:@"voicepack"]];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    93
    [self sendToEngine: voicepack];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    94
    [voicepack release];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    95
    
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    96
    NSString *flag = [[NSString alloc] initWithFormat:@"eflag %@", [teamData objectForKey:@"flag"]];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    97
    [self sendToEngine: flag];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    98
    [flag release];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
    99
    
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   100
    NSArray *hogs = [teamData objectForKey:@"hedgehogs"];
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   101
    for (int i = 0; i < numberOfPlayingHogs; i++) {
3199
1a9938a27677 fixes to the mac build system
koda
parents: 3170
diff changeset
   102
        NSDictionary *hog = [hogs objectAtIndex:i];
1a9938a27677 fixes to the mac build system
koda
parents: 3170
diff changeset
   103
        
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   104
        NSString *hogLevelHealthAndName = [[NSString alloc] initWithFormat:@"eaddhh %@ %d %@", 
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   105
                                           [hog objectForKey:@"level"], initialHealth, [hog objectForKey:@"hogname"]];
3170
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   106
        [self sendToEngine: hogLevelHealthAndName];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   107
        [hogLevelHealthAndName release];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   108
        
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   109
        NSString *hogHat = [[NSString alloc] initWithFormat:@"ehat %@", [hog objectForKey:@"hat"]];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   110
        [self sendToEngine: hogHat];
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   111
        [hogHat release];
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
   112
    }
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
   113
    
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
   114
    [teamData release];
3349
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   115
}
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   116
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   117
// unpacks ammostore data from the selected ammo.plist to a sequence of engine commands
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   118
-(void) provideAmmoData:(NSString *)ammostoreName forPlayingTeams:(NSInteger) numberOfTeams {
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   119
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   120
    //NSDictionary *ammoData = [[NSDictionary alloc] initWithContentsOfFile:ammoDataFile];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   121
    NSDictionary *ammoData = [[NSDictionary alloc] initWithObjectsAndKeys:
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   122
                              @"9391929422199121032235111001201000000211190911",@"ammostore_initialqt",
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   123
                              @"0405040541600655546554464776576666666155501000",@"ammostore_probability",
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   124
                              @"0000000000000205500000040007004000000000200000",@"ammostore_delay",
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   125
                              @"1311110312111111123114111111111111111211101111",@"ammostore_crate", nil];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   126
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   127
    
3349
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   128
    NSString *ammloadt = [[NSString alloc] initWithFormat:@"eammloadt %@", [ammoData objectForKey:@"ammostore_initialqt"]];
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   129
    [self sendToEngine: ammloadt];
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   130
    [ammloadt release];
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   131
    
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   132
    NSString *ammprob = [[NSString alloc] initWithFormat:@"eammprob %@", [ammoData objectForKey:@"ammostore_probability"]];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   133
    [self sendToEngine: ammprob];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   134
    [ammprob release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   135
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   136
    NSString *ammdelay = [[NSString alloc] initWithFormat:@"eammdelay %@", [ammoData objectForKey:@"ammostore_delay"]];
3349
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   137
    [self sendToEngine: ammdelay];
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   138
    [ammdelay release];
3170
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   139
    
3349
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   140
    NSString *ammreinf = [[NSString alloc] initWithFormat:@"eammreinf %@", [ammoData objectForKey:@"ammostore_crate"]];
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   141
    [self sendToEngine: ammreinf];
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   142
    [ammreinf release];
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   143
    
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   144
    // sent twice so it applies to both teams
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   145
    NSString *ammstore = [[NSString alloc] initWithString:@"eammstore"];
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   146
    for (int i = 0; i < numberOfTeams; i++)
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
   147
        [self sendToEngine: ammstore];
3349
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   148
    [ammstore release];
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   149
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   150
    [ammoData release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   151
}
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   152
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   153
// unpacks scheme data from the selected scheme.plist to a sequence of engine commands
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   154
-(NSInteger) provideScheme:(NSString *)schemeName {
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   155
    NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),schemeName];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   156
    NSArray *scheme = [[NSArray alloc] initWithContentsOfFile:schemePath];
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   157
    [schemePath release];
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   158
    int result = 0;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   159
    int i = 0;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   160
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   161
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   162
        result |= 0x01;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   163
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   164
        result |= 0x10;    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   165
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   166
        result |= 0x04;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   167
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   168
        result |= 0x08;    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   169
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   170
        result |= 0x20;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   171
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   172
        result |= 0x40;    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   173
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   174
        result |= 0x80;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   175
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   176
        result |= 0x100;    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   177
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   178
        result |= 0x200;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   179
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   180
        result |= 0x400;    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   181
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   182
        result |= 0x800;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   183
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   184
        result |= 0x2000;    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   185
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   186
        result |= 0x4000;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   187
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   188
        result |= 0x8000;    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   189
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   190
        result |= 0x10000;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   191
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   192
        result |= 0x20000;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   193
    if ([[scheme objectAtIndex:i++] boolValue])
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   194
        result |= 0x80000;    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   195
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   196
    NSString *flags = [[NSString alloc] initWithFormat:@"e$gmflags %d",result];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   197
    [self sendToEngine:flags];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   198
    [flags release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   199
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   200
    NSString *dmgMod = [[NSString alloc] initWithFormat:@"e$damagepct %d",[[scheme objectAtIndex:i++] intValue]];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   201
    [self sendToEngine:dmgMod];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   202
    [dmgMod release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   203
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   204
    NSString *turnTime = [[NSString alloc] initWithFormat:@"e$turntime %d",[[scheme objectAtIndex:i++] intValue] * 1000];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   205
    [self sendToEngine:turnTime];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   206
    [turnTime release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   207
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   208
    result = [[scheme objectAtIndex:i++] intValue]; // initial health
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   209
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   210
    NSString *sdTime = [[NSString alloc] initWithFormat:@"e$sd_turns %d",[[scheme objectAtIndex:i++] intValue]];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   211
    [self sendToEngine:sdTime];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   212
    [sdTime release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   213
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   214
    NSString *crateDrops = [[NSString alloc] initWithFormat:@"e$casefreq %d",[[scheme objectAtIndex:i++] intValue]];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   215
    [self sendToEngine:crateDrops];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   216
    [crateDrops release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   217
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   218
    NSString *minesTime = [[NSString alloc] initWithFormat:@"e$minestime %d",[[scheme objectAtIndex:i++] intValue] * 1000];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   219
    [self sendToEngine:minesTime];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   220
    [minesTime release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   221
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   222
    NSString *minesNumber = [[NSString alloc] initWithFormat:@"e$landadds %d",[[scheme objectAtIndex:i++] intValue]];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   223
    [self sendToEngine:minesNumber];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   224
    [minesNumber release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   225
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   226
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   227
    NSString *dudMines = [[NSString alloc] initWithFormat:@"e$minedudpct %d",[[scheme objectAtIndex:i++] intValue]];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   228
    [self sendToEngine:dudMines];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   229
    [dudMines release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   230
    
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   231
    NSString *explosives = [[NSString alloc] initWithFormat:@"e$explosives %d",[[scheme objectAtIndex:i++] intValue]];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   232
    [self sendToEngine:explosives];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   233
    [explosives release];
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   234
    
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   235
    [scheme release];
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   236
    return result;
3170
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   237
}
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   238
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   239
// method that handles net setup with engine and keeps connection alive
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   240
-(void) engineProtocol {
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   241
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   242
	IPaddress ip;
2705
2b5625c4ec16 fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents: 2702
diff changeset
   243
	int eProto;
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   244
	BOOL clientQuit, serverQuit;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   245
	char buffer[BUFFER_SIZE], string[BUFFER_SIZE];
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   246
	uint8_t msgSize;
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   247
	uint16_t gameTicks;
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   248
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   249
    serverQuit = NO;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   250
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   251
	if (SDLNet_Init() < 0) {
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   252
		NSLog(@"SDLNet_Init: %s", SDLNet_GetError());
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   253
        serverQuit = YES;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   254
	}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   255
	
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   256
	// Resolving the host using NULL make network interface to listen
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2693
diff changeset
   257
	if (SDLNet_ResolveHost(&ip, NULL, ipcPort) < 0) {
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   258
		NSLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError());
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   259
        serverQuit = YES;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   260
	}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   261
	
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   262
	// Open a connection with the IP provided (listen on the host's port) 
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   263
	if (!(sd = SDLNet_TCP_Open(&ip))) {
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2705
diff changeset
   264
		NSLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), ipcPort);
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   265
        serverQuit = YES;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   266
	}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   267
	
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   268
	NSLog(@"engineProtocol - Waiting for a client on port %d", ipcPort);
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   269
	while (!serverQuit) {
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   270
		// This check the sd if there is a pending connection.
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   271
        // If there is one, accept that, and open a new socket for communicating
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   272
		csd = SDLNet_TCP_Accept(sd);
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   273
		if (NULL != csd) {
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   274
			// Now we can communicate with the client using csd socket
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   275
			// sd will remain opened waiting other connections
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   276
			NSLog(@"engineProtocol - Client found");
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   277
			
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   278
			//first byte of the command alwayas contain the size of the command
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   279
			SDLNet_TCP_Recv(csd, &msgSize, sizeof(uint8_t));
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   280
			
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   281
			SDLNet_TCP_Recv(csd, buffer, msgSize);
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   282
			gameTicks = SDLNet_Read16 (&buffer[msgSize - 2]);
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   283
			//NSLog(@"engineProtocol - %d: received [%s]", gameTicks, buffer);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   284
			
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   285
			if ('C' == buffer[0]) {
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   286
				NSLog(@"engineProtocol - sending game config");
3199
1a9938a27677 fixes to the mac build system
koda
parents: 3170
diff changeset
   287
                
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   288
				// local game
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   289
				[self sendToEngine:@"TL"];
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   290
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   291
				// seed info
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   292
				[self sendToEngine:[self.gameConfig objectForKey:@"seed_command"]];
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   293
				
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   294
                // scheme (returns initial health)
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
   295
                NSInteger health = [self provideScheme:@"Scheme 0"];
2753
2305bb5dc5f2 update iphone port to new code from Smaxx
koda
parents: 2743
diff changeset
   296
2698
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   297
				// dimension of the map
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   298
				[self sendToEngine:[self.gameConfig objectForKey:@"templatefilter_command"]];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   299
				[self sendToEngine:[self.gameConfig objectForKey:@"mapgen_command"]];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   300
				[self sendToEngine:[self.gameConfig objectForKey:@"mazesize_command"]];
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   301
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   302
				// theme info
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   303
				[self sendToEngine:[self.gameConfig objectForKey:@"theme_command"]];
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   304
				
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   305
                NSArray *teamsConfig = [self.gameConfig objectForKey:@"teams_list"];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3364
diff changeset
   306
                for (NSDictionary *teamData in teamsConfig) {
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   307
                    [self provideTeamData:[teamData objectForKey:@"team"] 
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   308
                                  forHogs:[[teamData objectForKey:@"number"] intValue]
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   309
                               withHealth:health
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   310
                                  ofColor:[teamData objectForKey:@"color"]];
3170
1dbf4f8eaac0 ifrontend: predispone teams in a proper data structure
koda
parents: 3165
diff changeset
   311
                }
3349
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   312
                
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   313
                [self provideAmmoData:nil forPlayingTeams:[teamsConfig count]];
3349
5571592f10a8 update ifrontend to latest ammostore protocol
koda
parents: 3335
diff changeset
   314
                
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
   315
                clientQuit = NO;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   316
			} else {
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   317
				NSLog(@"engineProtocolThread - wrong message or client closed connection");
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   318
				clientQuit = YES;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   319
			}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   320
			
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   321
			while (!clientQuit){
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   322
				msgSize = 0;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   323
				memset(buffer, 0, BUFFER_SIZE);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   324
				memset(string, 0, BUFFER_SIZE);
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3395
diff changeset
   325
				if (SDLNet_TCP_Recv(csd, &msgSize, sizeof(uint8_t)) <= 0)
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   326
					clientQuit = YES;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   327
				if (SDLNet_TCP_Recv(csd, buffer, msgSize) <=0)
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   328
					clientQuit = YES;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   329
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   330
				gameTicks = SDLNet_Read16(&buffer[msgSize - 2]);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   331
				//NSLog(@"engineProtocolThread - %d: received [%s]", gameTicks, buffer);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   332
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   333
				switch (buffer[0]) {
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   334
					case '?':
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   335
						NSLog(@"Ping? Pong!");
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   336
						[self sendToEngine:@"!"];
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   337
						break;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   338
					case 'E':
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   339
						NSLog(@"ERROR - last console line: [%s]", buffer);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   340
						clientQuit = YES;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   341
						break;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   342
					case 'e':
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   343
						sscanf(buffer, "%*s %d", &eProto);
3328
fe87c2242984 fix the save of the team and rearrange hat/name modification
koda
parents: 3312
diff changeset
   344
						short int netProto = 0;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2753
diff changeset
   345
						char *versionStr;
3199
1a9938a27677 fixes to the mac build system
koda
parents: 3170
diff changeset
   346
						
3006
da6023c2745b restore compilation on simulator and device
koda
parents: 2799
diff changeset
   347
                        HW_versionInfo(&netProto, &versionStr);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2753
diff changeset
   348
						if (netProto == eProto) {
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2753
diff changeset
   349
							NSLog(@"Setting protocol version %d (%s)", eProto, versionStr);
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   350
						} else {
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   351
							NSLog(@"ERROR - wrong protocol number: [%s] - expecting %d", buffer, eProto);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   352
							clientQuit = YES;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   353
						}
3199
1a9938a27677 fixes to the mac build system
koda
parents: 3170
diff changeset
   354
                        
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   355
						break;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   356
					case 'i':
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   357
						switch (buffer[1]) {
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   358
							case 'r':
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   359
								NSLog(@"Winning team: %s", &buffer[2]);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   360
								break;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   361
							case 'k':
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   362
								NSLog(@"Best Hedgehog: %s", &buffer[2]);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   363
								break;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   364
						}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   365
						break;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   366
					default:
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   367
						// empty packet or just statistics
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   368
						break;
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   369
					// missing case for exiting right away
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   370
				}
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   371
			}
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   372
			NSLog(@"Engine exited, closing server");
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   373
			// wait a little to let the client close cleanly
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   374
			[NSThread sleepForTimeInterval:2];
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   375
			// Close the client socket
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   376
			SDLNet_TCP_Close(csd);
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   377
			serverQuit = YES;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   378
		}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   379
	}
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   380
	
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   381
	SDLNet_TCP_Close(sd);
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   382
	SDLNet_Quit();
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   383
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   384
    [[NSFileManager defaultManager] removeItemAtPath:GAMECONFIG_FILE() error:NULL];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   385
    
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   386
	[pool release];
3490
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
   387
    //Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.
016b3172b645 a bunch of minor stuff
koda
parents: 3487
diff changeset
   388
    //[NSThread exit];
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   389
}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   390
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   391
#pragma mark -
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   392
#pragma mark Setting methods
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   393
// returns an array of c-strings that are read by engine at startup
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   394
-(const char **)getSettings {
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   395
	NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort];
3006
da6023c2745b restore compilation on simulator and device
koda
parents: 2799
diff changeset
   396
	NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]];
3021
1d3302ac371f move the buttons a little
koda
parents: 3006
diff changeset
   397
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
3029
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3021
diff changeset
   398
    NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width];
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3021
diff changeset
   399
    NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height];
3495
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents: 3490
diff changeset
   400
	const char **gameArgs = (const char**) malloc(sizeof(char *) * 9);
3165
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   401
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   402
    /*
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   403
    size_t size;
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   404
    // Set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   405
    sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   406
    char *name = malloc(size);
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   407
    // Get the platform name
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   408
    sysctlbyname("hw.machine", name, &size, NULL, 0);
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   409
    NSString *machine = [[NSString alloc] initWithUTF8String:name];
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   410
    free(name);
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   411
    
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   412
   	const char **gameArgs = (const char**) malloc(sizeof(char*) * 9);
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   413
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   414
    // if the machine is less than iphone 3gs or less than ipod touch 3g use reduced graphics (land array)
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   415
    if ([machine hasPrefix:@"iPhone1"] || ([machine hasPrefix:@"iPod"] && ([machine hasSuffix:@"1,1"] || [machine hasSuffix:@"2,1"])))
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   416
        gameArgs[8] = "1";
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   417
    else
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   418
        gameArgs[8] = "0";
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   419
    [machine release];
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3090
diff changeset
   420
    */
3021
1d3302ac371f move the buttons a little
koda
parents: 3006
diff changeset
   421
    
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3221
diff changeset
   422
    // prevents using an empty nickname
6d8f1c76756d restore and update the old general settings
koda
parents: 3221
diff changeset
   423
    NSString *username;
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
   424
    NSString *originalUsername = [self.systemSettings objectForKey:@"username"];
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   425
    if ([originalUsername length] == 0)
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3221
diff changeset
   426
        username = [[NSString alloc] initWithFormat:@"MobileUser-%@",ipcString];
3373
c1ff724a5c34 use a proper bundle identifier
koda
parents: 3369
diff changeset
   427
    else
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3221
diff changeset
   428
        username = [[NSString alloc] initWithString:originalUsername];
6d8f1c76756d restore and update the old general settings
koda
parents: 3221
diff changeset
   429
    
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   430
	gameArgs[0] = [username UTF8String];                                                        //UserNick
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   431
	gameArgs[1] = [ipcString UTF8String];                                                       //ipcPort
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   432
	gameArgs[2] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String];       //isSoundEnabled
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   433
	gameArgs[3] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String];       //isMusicEnabled
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   434
	gameArgs[4] = [localeString UTF8String];                                                    //cLocaleFName
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3356
diff changeset
   435
	gameArgs[5] = [[[self.systemSettings objectForKey:@"alternate"] stringValue] UTF8String];	//cAltDamage
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   436
	gameArgs[6] = [wSize UTF8String];                                                           //cScreenHeight
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3365
diff changeset
   437
    gameArgs[7] = [hSize UTF8String];                                                           //cScreenWidth
3495
a6b4f351d400 now engine can be optionally built as library, there's an example wrapper of how to use it
koda
parents: 3490
diff changeset
   438
    gameArgs[8] = NULL;                                                                         //recordFileName
3021
1d3302ac371f move the buttons a little
koda
parents: 3006
diff changeset
   439
    
3029
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3021
diff changeset
   440
    [wSize release];
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3021
diff changeset
   441
    [hSize release];
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   442
	[localeString release];
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   443
	[ipcString release];
3312
6d8f1c76756d restore and update the old general settings
koda
parents: 3221
diff changeset
   444
    [username release];
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2699
diff changeset
   445
	return gameArgs;
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   446
}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   447
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   448
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   449
@end