cocoaTouch/GameSetup.m
author koda
Wed, 03 Feb 2010 23:36:42 +0000
changeset 2743 39d097ac2276
parent 2738 bfccb2ec4334
child 2753 2305bb5dc5f2
permissions -rw-r--r--
implement transition in the way i had in mind
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
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
    18
@synthesize 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];
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
    22
	srandom(time(NULL));
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2705
diff changeset
    23
	ipcPort = (random() % 64541) + 1025;
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
    24
		
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
    25
	NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"];
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
    26
	self.systemSettings = [[NSDictionary alloc] initWithContentsOfFile:filePath]; //should check it exists
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
    27
	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
    28
}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    29
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    30
-(void) dealloc {
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    31
	[super dealloc];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    32
}
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
#pragma mark -
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    35
#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
    36
-(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
    37
	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
    38
	[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
    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
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    41
-(int) sendToEngine: (NSString *)string {
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    42
	Uint8 length = [string length];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    43
	
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    44
	SDLNet_TCP_Send(csd, &length , 1);
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    45
	return SDLNet_TCP_Send(csd, [string UTF8String], length);
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    46
}
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    47
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
    48
-(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
    49
	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
    50
	IPaddress ip;
2705
2b5625c4ec16 fix a nasty 196 bytes memory leak in engine, plus other stuff for iphone frontend
koda
parents: 2702
diff changeset
    51
	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
    52
	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
    53
	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
    54
	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
    55
	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
    56
	
3207e0eacd43 GameSetup is now 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
	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
    58
		NSLog(@"SDLNet_Init: %s", SDLNet_GetError());
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
    59
		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
    60
	}
3207e0eacd43 GameSetup is now 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
	
3207e0eacd43 GameSetup is now 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
	/* 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
    63
	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
    64
		NSLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError());
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
    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
	/* 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
    69
	if (!(sd = SDLNet_TCP_Open(&ip))) {
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2705
diff changeset
    70
		NSLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), 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
    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
	
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
    74
	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
    75
	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
    76
	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
    77
		
3207e0eacd43 GameSetup is now 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
		/* 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
    79
		 * 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
    80
		csd = SDLNet_TCP_Accept(sd);
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
    81
		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
    82
			
3207e0eacd43 GameSetup is now 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
			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
    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
			//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
    86
			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
    87
			
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
    88
			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
    89
			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
    90
			//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
    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
			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
    93
				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
    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
				// send config data data
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
    96
				/*
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
    97
				seed is arbitrary string
2698
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
    98
				addteam <color> <team name>
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
    99
				addhh <level> <health> <hedgehog name>
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
   100
				  <level> is 0 for human, 1-5 for bots (5 is the most stupid)
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2716
diff changeset
   101
				ammostore is one byte/number for each ammocount then one for each probability or so
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2716
diff changeset
   102
				*/
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
   103
				// local game
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   104
				[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
   105
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   106
				// seed info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   107
				[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
   108
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   109
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   110
				[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
   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
				// various flags
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   113
				[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
   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$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
   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$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
   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$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
   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$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
   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$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
   129
				
2698
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
   130
				// dimension of the map
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   131
				[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
   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
				// theme info
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2716
diff changeset
   134
				[self sendToEngine:@"etheme Compost"];
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
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   136
				// team 1 info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   137
				[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
   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
				// team 1 grave info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   140
				[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
   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 fort info
2699
249adefa9c1c replace initialization/finalization statements with custom init functions
koda
parents: 2698
diff changeset
   143
				[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
   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 voicepack info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   146
				[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
   147
				
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   148
				// 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
   149
				// team 1 members info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   150
				[self sendToEngine:@"eaddhh 0 100 Snow Leopard"];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   151
				[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
   152
				
3207e0eacd43 GameSetup is now 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
				// team 1 ammostore
2734
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2716
diff changeset
   154
				[self sendToEngine:@"eammstore 20501090003040000009000000000000000000010404000441400444645644444774776112211144"];
fb9ad1587054 smaller improvements in mouse handling
koda
parents: 2716
diff changeset
   155
				//[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
   156
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   157
				// team 2 info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   158
				[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
   159
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   160
				// team 2 grave info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   161
				[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
   162
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   163
				// team 2 fort info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   164
				[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
   165
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   166
				// team 2 voicepack info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   167
				[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
   168
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   169
				// 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
   170
				// team 2 members info
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   171
				[self sendToEngine:@"eaddhh 0 100 Raichu"];
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   172
				[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
   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 ammostore
2738
bfccb2ec4334 new graphics from Tiy and frontend is loaded in landscape mode
koda
parents: 2734
diff changeset
   175
				[self sendToEngine:@"eammstore 20501090003040000009000000000000000000010404000441400444645644444774776112211144"];
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
   176
				
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   177
				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
   178
			} else {
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   179
				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
   180
				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
   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
			
3207e0eacd43 GameSetup is now 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
			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
   184
				/* 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
   185
				 * 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
   186
				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
   187
				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
   188
				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
   189
				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
   190
					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
   191
				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
   192
					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
   193
				
3207e0eacd43 GameSetup is now 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
				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
   195
				//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
   196
				
3207e0eacd43 GameSetup is now 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
				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
   198
					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
   199
						NSLog(@"Ping? Pong!");
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   200
						[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
   201
						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
   202
					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
   203
						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
   204
						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
   205
						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
   206
					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
   207
						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
   208
						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
   209
							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
   210
						} 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
   211
							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
   212
							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
   213
						}
3207e0eacd43 GameSetup is now 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
						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
   215
					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
   216
						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
   217
							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
   218
								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
   219
								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
   220
							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
   221
								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
   222
								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
   223
						}
3207e0eacd43 GameSetup is now 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
						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
   225
					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
   226
						// 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
   227
						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
   228
					// missing case for exiting right away
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   229
				}
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
   230
			}
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
   231
			NSLog(@"Engine exited, closing server");
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   232
			// 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
   233
			[NSThread sleepForTimeInterval:2];
2697
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   234
			// Close the client socket
75880595a9f1 code cleanup and opengles optimizations
koda
parents: 2696
diff changeset
   235
			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
   236
			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
   237
		}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   238
	}
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
   239
	
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
	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
   241
	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
   242
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   243
	[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
   244
	[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
   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
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   247
#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
   248
#pragma mark Setting methods
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
   249
-(const char **)getSettings {
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2738
diff changeset
   250
	const char **gameArgs = (const char**) malloc(sizeof(char*) * 6);
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
   251
	NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort];
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
	NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] localeIdentifier]];
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   253
	
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
   254
	gameArgs[0] = [[systemSettings objectForKey:@"username"] UTF8String];	//UserNick
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
   255
	gameArgs[1] = [ipcString UTF8String];					//ipcPort
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
   256
	gameArgs[2] = [[systemSettings objectForKey:@"sounds"] UTF8String];	//isSoundEnabled
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
   257
	gameArgs[3] = [[systemSettings objectForKey:@"music"] UTF8String];	//isMusicEnabled
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
	gameArgs[4] = [localeString UTF8String];				//cLocaleFName
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2738
diff changeset
   259
	gameArgs[5] = [[systemSettings objectForKey:@"alternate"] UTF8String];	//cAltDamage
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
   260
	
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
   261
	[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
   262
	[ipcString 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
   263
	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
   264
}
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents:
diff changeset
   265
3207e0eacd43 GameSetup is now 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
@end