# HG changeset patch # User koda # Date 1304464779 -7200 # Node ID 7b9aa7aac33687b956fa074b703e06fa3e37d1c0 # Parent 7440fe992e738b28144e3defdba650e560016cc0 * moved colours and default port from .cpp.in to .h * slight tweaks to existing colours (softer shades) diff -r 7440fe992e73 -r 7b9aa7aac336 QTfrontend/frameTeam.cpp --- a/QTfrontend/frameTeam.cpp Tue May 03 23:16:47 2011 +0200 +++ b/QTfrontend/frameTeam.cpp Wed May 04 01:19:39 2011 +0200 @@ -37,8 +37,8 @@ mainLayout.setContentsMargins(4, 4, 4, 4); int i = 0; - while(colors[i]) - availableColors.push_back(*colors[i++]); + while(colors[i] != 0) + availableColors.push_back(QColor(colors[i++])); resetColors(); } diff -r 7440fe992e73 -r 7b9aa7aac336 QTfrontend/game.cpp --- a/QTfrontend/game.cpp Tue May 03 23:16:47 2011 +0200 +++ b/QTfrontend/game.cpp Wed May 04 01:19:39 2011 +0200 @@ -19,6 +19,7 @@ #include #include #include +#include #include "game.h" #include "hwconsts.h" @@ -117,7 +118,7 @@ HWTeam * team1; team1 = new HWTeam; team1->difficulty = 0; - team1->teamColor = *colors[0]; + team1->teamColor = QColor(colors[0]); team1->numHedgehogs = 4; namegen.TeamRandomNames(team1,TRUE); HWProto::addStringListToBuffer(teamscfg, @@ -126,7 +127,7 @@ HWTeam * team2; team2 = new HWTeam; team2->difficulty = 4; - team2->teamColor = *colors[1]; + team2->teamColor = QColor(colors[1]); team2->numHedgehogs = 4; do namegen.TeamRandomNames(team2,TRUE); diff -r 7440fe992e73 -r 7b9aa7aac336 QTfrontend/hwconsts.cpp.in --- a/QTfrontend/hwconsts.cpp.in Tue May 03 23:16:47 2011 +0200 +++ b/QTfrontend/hwconsts.cpp.in Wed May 04 01:19:39 2011 +0200 @@ -64,20 +64,10 @@ AMMOLINE_PORTALS_DELAY AMMOLINE_PORTALS_CRATE )) ; -QColor *colors[] = { - new QColor(221, 0, 0), // classic red - new QColor( 51, 102, 217), // dark blue - new QColor( 62, 147, 33), // classic green - new QColor(162, 61, 187), // classic purple - new QColor(255, 255, 0), // yellow - new QColor(115, 115, 115), // classic gray - new QColor(0, 255, 255), // cyan - new QColor(255, 136, 136), // peach - // add new colors here - 0}; +unsigned int colors[] = HW_TEAMCOLOR_ARRAY; QString * netHost = new QString(); -quint16 netPort = 46631; +quint16 netPort = NETGAME_DEFAULT_PORT; bool haveServer = ${HAVE_NETSERVER}; bool isDevBuild = ${HW_DEV}; diff -r 7440fe992e73 -r 7b9aa7aac336 QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Tue May 03 23:16:47 2011 +0200 +++ b/QTfrontend/hwconsts.h Wed May 04 01:19:39 2011 +0200 @@ -20,7 +20,6 @@ #include #include #include -#include #include extern QString * cProtoVer; @@ -46,7 +45,7 @@ extern int cAmmoNumber; extern QList< QPair > cDefaultAmmos; -extern QColor *colors[]; +extern unsigned int colors[]; extern QString * netHost; extern quint16 netPort; @@ -91,3 +90,18 @@ #define AMMOLINE_PORTALS_DELAY "000000000000020550000004000700400000000020000000060000" #define AMMOLINE_PORTALS_CRATE "131111031211111112311411111111111111121111110111111111" + +#define NETGAME_DEFAULT_PORT 46631 + + +// see http://en.wikipedia.org/wiki/List_of_colors +#define HW_TEAMCOLOR_ARRAY { 0xff007fff, /* azure */ \ + 0xffdd0000, /* classic red */ \ + 0xff3e9321, /* classic green */ \ + 0xffa23dbb, /* classic purple */ \ + 0xffffb347, /* pastel orange */ \ + 0xffcfcfc4, /* pastel gray */ \ + 0xffbff000, /* lime */ \ + 0xffffef00, /* yellow */ \ + /* add new colors here */ \ + 0 } diff -r 7440fe992e73 -r 7b9aa7aac336 project_files/HedgewarsMobile/Classes/CommodityFunctions.h --- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.h Tue May 03 23:16:47 2011 +0200 +++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.h Wed May 04 01:19:39 2011 +0200 @@ -63,8 +63,6 @@ #define IS_NOT_VERY_POWERFUL() ([modelType() hasPrefix:@"iPad1"] || [modelType() hasPrefix:@"iPhone2"] || [modelType() hasPrefix:@"iPod3"] || [modelType() hasPrefix:@"iPod4"] ) #define IS_VERY_POWERFUL() (IS_NOT_POWERFUL() == NO && IS_NOT_VERY_POWERFUL() == NO) -#define DEFAULT_NETGAME_PORT 46631 - void print_free_memory (void); void playSound (NSString *snd); diff -r 7440fe992e73 -r 7b9aa7aac336 project_files/HedgewarsMobile/Classes/CommodityFunctions.m --- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.m Tue May 03 23:16:47 2011 +0200 +++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.m Wed May 04 01:19:39 2011 +0200 @@ -28,6 +28,7 @@ #import #import #import "PascalImports.h" +#import "hwconsts.h" BOOL inline rotationManager (UIInterfaceOrientation interfaceOrientation) { return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || @@ -37,7 +38,7 @@ NSInteger inline randomPort () { srandom(time(NULL)); NSInteger res = (random() % 64511) + 1024; - return (res == DEFAULT_NETGAME_PORT) ? randomPort() : res; + return (res == NETGAME_DEFAULT_PORT) ? randomPort() : res; } void popError (const char *title, const char *message) { @@ -107,16 +108,17 @@ } } -NSArray inline *getAvailableColors (void) { - return [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x3376E9], // bluette - [NSNumber numberWithUnsignedInt:0x3e9321], // greeeen - [NSNumber numberWithUnsignedInt:0xa23dbb], // violett - [NSNumber numberWithUnsignedInt:0xff9329], // oranngy - [NSNumber numberWithUnsignedInt:0xdd0000], // reddish - [NSNumber numberWithUnsignedInt:0x737373], // graaaay - [NSNumber numberWithUnsignedInt:0x00FFFF], // cyannnn - [NSNumber numberWithUnsignedInt:0xFF8888], // peachyj - nil]; +NSArray *getAvailableColors (void) { + unsigned int colors[] = HW_TEAMCOLOR_ARRAY; + NSMutableArray *array = [[NSMutableArray alloc] init]; + + int i = 0; + while(colors[i] != 0) + [array addObject:[NSNumber numberWithUnsignedInt:(colors[i++] & 0x00FFFFFF)]]; + + NSArray *final = [NSArray arrayWithArray:array]; + [array release]; + return final; } UILabel *createBlueLabel (NSString *title, CGRect frame) { diff -r 7440fe992e73 -r 7b9aa7aac336 project_files/HedgewarsMobile/Classes/ServerSetup.m --- a/project_files/HedgewarsMobile/Classes/ServerSetup.m Tue May 03 23:16:47 2011 +0200 +++ b/project_files/HedgewarsMobile/Classes/ServerSetup.m Wed May 04 01:19:39 2011 +0200 @@ -24,6 +24,7 @@ #import "CommodityFunctions.h" #import #import +#import "hwconsts.h" #define BUFFER_SIZE 256 @@ -105,18 +106,18 @@ } // Resolving the host using NULL make network interface to listen - if (SDLNet_ResolveHost(&ip, "netserver.hedgewars.org", DEFAULT_NETGAME_PORT) < 0 && !clientQuit) { + if (SDLNet_ResolveHost(&ip, "netserver.hedgewars.org", NETGAME_DEFAULT_PORT) < 0 && !clientQuit) { DLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError()); clientQuit = YES; } // Open a connection with the IP provided (listen on the host's port) if (!(sd = SDLNet_TCP_Open(&ip)) && !clientQuit) { - DLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), DEFAULT_NETGAME_PORT); + DLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), NETGAME_DEFAULT_PORT); clientQuit = YES; } - DLog(@"Found server on port %d", DEFAULT_NETGAME_PORT); + DLog(@"Found server on port %d", NETGAME_DEFAULT_PORT); while (!clientQuit) { int index = 0; BOOL exitBufferLoop = NO;