cocoaTouch/GameSetup.m
author koda
Mon, 18 Jan 2010 05:36:08 +0000
changeset 2699 249adefa9c1c
parent 2698 90585aba87ad
child 2702 48fc46a922fd
permissions -rw-r--r--
replace initialization/finalization statements with custom init functions
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
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
     9
#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
    10
#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
    11
#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
    12
#import "PascalImports.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
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
#define BUFFER_SIZE 256
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
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
    16
@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
    17
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2693
diff changeset
    18
@synthesize localeString, systemSettings;
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
    19
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
-(id) init {
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
	self = [super init];
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2693
diff changeset
    22
	self.localeString = [[[NSLocale currentLocale] localeIdentifier] stringByAppendingString:@".txt"];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2693
diff changeset
    23
	self.systemSettings = nil;
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2693
diff changeset
    24
	engineProtocolStarted = NO;
2698
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
    25
	ipcPort = 51432;
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
    26
	return self;
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
    27
}
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
    28
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    29
-(void) dealloc {
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
    30
	if (systemSettings) [self.systemSettings release];
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    31
	[self.localeString autorelease];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    32
	[super dealloc];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    33
}
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    34
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    35
#pragma mark -
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    36
#pragma mark Thread/Network relevant code
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
    37
-(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
    38
	SEL usage = NSSelectorFromString(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
    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
	// do not start the server thread because the port is already bound
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
    41
	if (NO == engineProtocolStarted) {
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
    42
		engineProtocolStarted = 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
    43
		[NSThread detachNewThreadSelector:usage toTarget:self withObject:nil];
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
    44
	}
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
    45
}
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
    46
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    47
-(int) sendToEngine: (NSString *)string {
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    48
	Uint8 length = [string length];
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
	SDLNet_TCP_Send(csd, &length , 1);
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    51
	return SDLNet_TCP_Send(csd, [string UTF8String], length);
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    52
}
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    53
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) engineProtocol {
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
	IPaddress ip;
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
    56
	int idx, 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
    57
	BOOL serverQuit, 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
    58
	char buffer[BUFFER_SIZE], string[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
    59
	Uint8 msgSize;
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
    60
	Uint16 gameTicks;
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
    61
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
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
    62
	
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
    63
	if (SDLNet_Init() < 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
    64
		fprintf(stderr, "SDLNet_Init: %s\n", SDLNet_GetError());
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
    65
		exit(EXIT_FAILURE);
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
    66
	}
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
    67
	
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
    68
	/* 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
    69
	if (SDLNet_ResolveHost(&ip, NULL, ipcPort) < 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
    70
		fprintf(stderr, "SDLNet_ResolveHost: %s\n", SDLNet_GetError());
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
    71
		exit(EXIT_FAILURE);
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
    72
	}
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
    73
	
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
    74
	/* Open a connection with the IP provided (listen on the host's port) */
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
    75
	if (!(sd = SDLNet_TCP_Open(&ip))) {
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
    76
		fprintf(stderr, "SDLNet_TCP_Open: %s\n", SDLNet_GetError());
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
    77
		exit(EXIT_FAILURE);
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
    78
	}
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
    79
	
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
    80
	NSLog(@"engineProtocol - Waiting for a client");
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
    81
	
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
    82
	serverQuit = NO;
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
    83
	while (!serverQuit) {
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
    84
		
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
    85
		/* This check the sd if there is a pending connection.
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
    86
		 * 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
    87
		csd = SDLNet_TCP_Accept(sd);
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
    88
		if (NULL != csd) {
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
    89
			
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
    90
			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
    91
			
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
    92
			//first byte of the command alwayas contain the size of the command
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
    93
			SDLNet_TCP_Recv(csd, &msgSize, sizeof(Uint8));
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
    94
			
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
    95
			SDLNet_TCP_Recv(csd, buffer, msgSize);
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
    96
			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
    97
			//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
    98
			
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
    99
			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
   100
				NSLog(@"engineProtocol - sending game config");
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
   101
				
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
   102
				// send config data data
2698
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   103
				/*seed is arbitrary string
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   104
				[16:12] unC0Rr:
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   105
				addteam <color> <team name>
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   106
				[16:13] unC0Rr:
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   107
				addhh <level> <health> <hedgehog name>
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   108
				[16:13] unC0Rr:
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   109
				<level> is 0 for human, 1-5 for bots (5 is the most stupid)*/				// local game
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   110
				[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
   111
				
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
   112
				// seed info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   113
				[self sendToEngine:@"eseed {232c1b42-7d39-4ee6-adf8-4240e1f1efb8}"];
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
   114
				
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
   115
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   116
				[self sendToEngine:@"e$gmflags 256"]; 
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
   117
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
   118
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   119
				[self sendToEngine:@"e$damagepct 100"];
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
   120
				
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
   121
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   122
				[self sendToEngine:@"e$turntime 45000"];
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
   123
				
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
   124
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   125
				[self sendToEngine:@"e$minestime 3000"];
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
   126
				
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
   127
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   128
				[self sendToEngine:@"e$landadds 4"];
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
   129
				
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
   130
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   131
				[self sendToEngine:@"e$sd_turns 15"];
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
   132
												
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
   133
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   134
				[self sendToEngine:@"e$casefreq 5"];
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
   135
				
2698
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   136
				// dimension of the map
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   137
				[self sendToEngine:@"e$template_filter 1"];
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
   138
								
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
   139
				// theme info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   140
				[self sendToEngine:@"etheme Freeway"];
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
   141
				
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
   142
				// team 1 info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   143
				[self sendToEngine:@"eaddteam 4421353 System Cats"];
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
   144
				
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
   145
				// team 1 grave info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   146
				[self sendToEngine:@"egrave star"];
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
   147
				
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
   148
				// team 1 fort info
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2698
diff changeset
   149
				[self sendToEngine:@"efort Earth"];
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
   150
								
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
   151
				// team 1 voicepack info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   152
				[self sendToEngine:@"evoicepack Classic"];
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
   153
				
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   154
				// team 1 binds (skipped)			
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
   155
				// team 1 members info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   156
				[self sendToEngine:@"eaddhh 0 100 Snow Leopard"];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   157
				[self sendToEngine:@"ehat NoHat"];
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
   158
				
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
   159
				// team 1 ammostore
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   160
				[self sendToEngine:@"eammstore 93919294221991210322351110012010000002110404000441400444645644444774776112211144"];
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
   161
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
   162
				// team 2 info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   163
				[self sendToEngine:@"eaddteam 4100897 Poke-MAN"];
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
   164
				
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
   165
				// team 2 grave info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   166
				[self sendToEngine:@"egrave Badger"];
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
   167
				
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
   168
				// team 2 fort info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   169
				[self sendToEngine:@"efort UFO"];
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
   170
				
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
   171
				// team 2 voicepack info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   172
				[self sendToEngine:@"evoicepack Classic"];
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
   173
				
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
   174
				// team 2 binds (skipped)
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
   175
				// team 2 members info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   176
				[self sendToEngine:@"eaddhh 0 100 Raichu"];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   177
				[self sendToEngine:@"ehat Bunny"];
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
   178
				
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
   179
				// team 2 ammostore
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   180
				[self sendToEngine:@"eammstore 93919294221991210322351110012010000002110404000441400444645644444774776112211144"];
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
   181
				
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
   182
				clientQuit = NO;
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
   183
			} else {
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   184
				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
   185
				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
   186
			}
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
   187
			
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
   188
			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
   189
				/* Now we can communicate with the client using csd socket
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
   190
				 * sd will remain opened waiting other connections */
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
   191
				idx = 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
   192
				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
   193
				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
   194
				memset(string, 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
   195
				if (SDLNet_TCP_Recv(csd, &msgSize, sizeof(Uint8)) <= 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
   196
					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
   197
				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
   198
					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
   199
				
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
   200
				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
   201
				//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
   202
				
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
   203
				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
   204
					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
   205
						NSLog(@"Ping? Pong!");
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   206
						[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
   207
						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
   208
					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
   209
						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
   210
						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
   211
						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
   212
					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
   213
						sscanf(buffer, "%*s %d", &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
   214
						if (HW_protoVer() == 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
   215
							NSLog(@"Setting protocol version %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
   216
						} 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
   217
							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
   218
							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
   219
						}
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
   220
						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
   221
					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
   222
						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
   223
							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
   224
								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
   225
								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
   226
							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
   227
								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
   228
								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
   229
						}
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
   230
						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
   231
					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
   232
						// 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
   233
						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
   234
					// missing case for exiting right away
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   235
				}
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
   236
			}
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   237
			NSLog(@"Client Exited");
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   238
			// wait a little to let the client close cleanly
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2698
diff changeset
   239
			sleep(2);
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   240
			// Close the client socket
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   241
			SDLNet_TCP_Close(csd);
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
		}
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   243
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
   244
	}
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
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
   246
	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
   247
	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
   248
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
   249
	[pool release];
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
   250
	[NSThread exit];
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
}
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
   252
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   253
#pragma mark -
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   254
#pragma mark Settings setup methods
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   255
-(void) loadSettingsFromFile:(NSString *)fileName forKey:(NSString *)objName {
2698
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   256
	NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:fileName];
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   257
	
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   258
	if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {	
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   259
		NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:filePath];
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2698
diff changeset
   260
		systemSettings = dict;
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2698
diff changeset
   261
		//[self setValue:dict forKey:objName];
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   262
		[dict release];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   263
	} else {
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   264
		//TODO create it
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   265
		[NSException raise:@"File NOT found" format:@"The file %@ was not found at %@", fileName, filePath];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   266
	}
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   267
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   268
}
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   269
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   270
-(void) unloadSettings {
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2698
diff changeset
   271
	systemSettings = 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
   272
}
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
   273
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
   274
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
   275
@end