You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(5) |
Apr
(10) |
May
|
Jun
(60) |
Jul
(11) |
Aug
|
Sep
(19) |
Oct
(25) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2009 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
From: <the...@us...> - 2007-06-12 11:09:06
|
Revision: 24 http://qonk.svn.sourceforge.net/qonk/?rev=24&view=rev Author: thebohemian Date: 2007-06-12 04:09:04 -0700 (Tue, 12 Jun 2007) Log Message: ----------- - added missing closing bracket Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/configure.ac Modified: branches/autoconf-2007-03-26-thebohemian/configure.ac =================================================================== --- branches/autoconf-2007-03-26-thebohemian/configure.ac 2007-06-12 11:07:17 UTC (rev 23) +++ branches/autoconf-2007-03-26-thebohemian/configure.ac 2007-06-12 11:09:04 UTC (rev 24) @@ -22,7 +22,7 @@ # Checks for libraries. AC_CHECK_LIB([SDL], [SDL_Init]) AC_CHECK_LIB([SDL_ttf], [TTF_Init], ,AC_MSG_ERROR([SDL_ttf missing. Please install at least version 2.0!])) -AC_CHECK_LIB([SDL_gfx], [pixelColor], ,AC_MSG_ERROR([SDL_gfx missing. Please install at least version 1.2!]) +AC_CHECK_LIB([SDL_gfx], [pixelColor], ,AC_MSG_ERROR([SDL_gfx missing. Please install at least version 1.2!])) # Checks for header files. AC_HEADER_STDC This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-06-12 11:07:20
|
Revision: 23 http://qonk.svn.sourceforge.net/qonk/?rev=23&view=rev Author: thebohemian Date: 2007-06-12 04:07:17 -0700 (Tue, 12 Jun 2007) Log Message: ----------- - Properly report error if SDL_ttf or SDL_gfx libraries are not found. Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/configure.ac Modified: branches/autoconf-2007-03-26-thebohemian/configure.ac =================================================================== --- branches/autoconf-2007-03-26-thebohemian/configure.ac 2007-04-05 01:44:29 UTC (rev 22) +++ branches/autoconf-2007-03-26-thebohemian/configure.ac 2007-06-12 11:07:17 UTC (rev 23) @@ -21,8 +21,8 @@ # Checks for libraries. AC_CHECK_LIB([SDL], [SDL_Init]) -AC_CHECK_LIB([SDL_ttf], [TTF_Init]) -AC_CHECK_LIB([SDL_gfx], [pixelColor]) +AC_CHECK_LIB([SDL_ttf], [TTF_Init], ,AC_MSG_ERROR([SDL_ttf missing. Please install at least version 2.0!])) +AC_CHECK_LIB([SDL_gfx], [pixelColor], ,AC_MSG_ERROR([SDL_gfx missing. Please install at least version 1.2!]) # Checks for header files. AC_HEADER_STDC This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-05 01:44:30
|
Revision: 22 http://qonk.svn.sourceforge.net/qonk/?rev=22&view=rev Author: thebohemian Date: 2007-04-04 18:44:29 -0700 (Wed, 04 Apr 2007) Log Message: ----------- - finished SDL_Surface argument removals - moved more drawing code into canvas Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp branches/autoconf-2007-03-26-thebohemian/src/canvas.h branches/autoconf-2007-03-26-thebohemian/src/planets.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.h branches/autoconf-2007-03-26-thebohemian/src/players.cpp branches/autoconf-2007-03-26-thebohemian/src/ships.cpp branches/autoconf-2007-03-26-thebohemian/src/universe.cpp Modified: branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp 2007-04-05 01:04:12 UTC (rev 21) +++ branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp 2007-04-05 01:44:29 UTC (rev 22) @@ -53,31 +53,34 @@ } void -Canvas::drawNearestPlanetSelector(Coordinate &c) +Canvas::drawNearestPlanetSelector(Coordinate &c, int size) { - drawSelector(c, -5, 10, 10, 255, 0, 0); + size *= 3; + int offset = -size/2; + + drawSelector(c, offset, size, size, 255, 0, 0); } void Canvas::drawPlanet( Coordinate &loc, int size, Uint32 color ) { - drawPlanetMapped(main, loc.getXMapped(), loc.getYMapped(), size, color); + drawPlanetMapped(loc.getXMapped(), loc.getYMapped(), size, color); } void -Canvas::drawPlanetMapped( SDL_Surface* screen, int x, int y, int size, Uint32 color ) { +Canvas::drawPlanetMapped(int x, int y, int size, Uint32 color ) { int R = getRed(color); int G = getGreen(color); int B = getBlue(color); - filledCircleRGBA( screen, x, y, size + 2, 0, 0, 0, 128 ); - filledCircleRGBA( screen, x, y, size, R, G, B, 255 ); - aacircleRGBA( screen, x, y, size, R, G, B, 255 ); - filledEllipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); - aaellipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); + filledCircleRGBA( main, x, y, size + 2, 0, 0, 0, 128 ); + filledCircleRGBA( main, x, y, size, R, G, B, 255 ); + aacircleRGBA( main, x, y, size, R, G, B, 255 ); + filledEllipseRGBA( main, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); + aaellipseRGBA( main, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); } void -Canvas::drawResidentShip(SDL_Surface* screen, Coordinate& shipLocation, Coordinate& planetLocation, +Canvas::drawResidentShip(Coordinate& shipLocation, Coordinate& planetLocation, int color) { int sx = shipLocation.getXMapped(); int sy = shipLocation.getYMapped(); @@ -89,12 +92,12 @@ int g = getGreen(color); int b = getBlue(color); - aalineRGBA( screen, sx, sy, px, py, r, g, b, 64 ); - filledCircleRGBA( screen, sx, sy, 1, r, g, b, 255 ); + aalineRGBA(main, sx, sy, px, py, r, g, b, 64); + filledCircleRGBA(main, sx, sy, 1, r, g, b, 255); } void -Canvas::drawFlyingShip(SDL_Surface *screen, Coordinate& shipLocation, double direction, int color) +Canvas::drawFlyingShip(Coordinate& shipLocation, double direction, int color) { int sx = shipLocation.getXMapped(); int sy = shipLocation.getYMapped(); @@ -114,15 +117,15 @@ rightTipX = (int) (sx + 2.0 * cos( direction - M_PI / 3.0)); rightTipY = (int) (sy + 2.0 * sin( direction - M_PI / 3.0)); - aalineRGBA(screen, leftTipX, leftTipY, headX, headY, r, g, b, 255); - aalineRGBA(screen, rightTipX, rightTipY, headX, headY, r, g, b, 255); - aalineRGBA(screen, rightTipX, rightTipY, leftTipX, leftTipY, r, g, b, 255); + aalineRGBA(main, leftTipX, leftTipY, headX, headY, r, g, b, 255); + aalineRGBA(main, rightTipX, rightTipY, headX, headY, r, g, b, 255); + aalineRGBA(main, rightTipX, rightTipY, leftTipX, leftTipY, r, g, b, 255); } void -Canvas::drawSelection(SDL_Surface *screen, Coordinate& location) +Canvas::drawSelection(Coordinate& location) { - aacircleRGBA(screen, location.getXMapped(), location.getYMapped(), 3, 255, 192, 0, 255 ); + aacircleRGBA(main, location.getXMapped(), location.getYMapped(), 3, 255, 192, 0, 255 ); } void @@ -138,6 +141,15 @@ r, g, b, 64); } +void +Canvas::drawBuildProgress(Coordinate& location, int size, double percentage) +{ + aacircleRGBA( main, location.getXMapped(), location.getYMapped(), + (int) (size + 102.5 - percentage), + 0xff, 0xff, 0xff, + (int)( 0.2 * percentage )); +} + SDL_Surface * Canvas::initScreen() { Modified: branches/autoconf-2007-03-26-thebohemian/src/canvas.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/canvas.h 2007-04-05 01:04:12 UTC (rev 21) +++ branches/autoconf-2007-03-26-thebohemian/src/canvas.h 2007-04-05 01:44:29 UTC (rev 22) @@ -21,21 +21,23 @@ Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ); - static void drawNearestPlanetSelector(Coordinate&); + static void drawNearestPlanetSelector(Coordinate&, int); static void drawPlanet(Coordinate&, int size, Uint32 color); - static void drawPlanetMapped(SDL_Surface* screen, int x, int y, int size, Uint32 color); + static void drawPlanetMapped(int x, int y, int size, Uint32 color); - static void drawResidentShip(SDL_Surface* screen, Coordinate& shipLocation, Coordinate& planetLocation, + static void drawResidentShip(Coordinate& shipLocation, Coordinate& planetLocation, int color); - static void drawFlyingShip(SDL_Surface *screen, Coordinate&, double direction, int color); + static void drawFlyingShip(Coordinate&, double direction, int color); - static void drawSelection(SDL_Surface *screen, Coordinate&); + static void drawSelection(Coordinate&); static void drawOrbit(Coordinate&, double rotationDistance, int color); + static void drawBuildProgress(Coordinate&, int, double); + static SDL_Surface *initScreen(); private: Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-05 01:04:12 UTC (rev 21) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-05 01:44:29 UTC (rev 22) @@ -1,7 +1,9 @@ // Copyright 2005 by Anthony Liekens an...@li... -#include <SDL/SDL_gfxPrimitives.h> +#include <math.h> +#include <SDL/SDL.h> + #include "planets.h" #include "timer.h" #include "ships.h" @@ -19,7 +21,7 @@ // ##### PLANET ##### -Planet::Planet() { +Planet::Planet() : nearestPlanet(false) { rotationSpeed = ( ( rand() % 2 ) * 2 - 1 ) * ( rand() % 60000 + 20000 ); rotationDistance = 0.05 + 0.4 * ( double )rand() / RAND_MAX; rotationOffset = rand() % 10000000; @@ -160,7 +162,7 @@ if (nearestPlanet) { - Canvas::drawNearestPlanetSelector(location); + Canvas::drawNearestPlanetSelector(location, size); } } @@ -188,8 +190,8 @@ int x = location.getXMapped(); int y = location.getYMapped(); double percentage = 100.0 * ( timer.getTime() - buildStartTime ) / ( buildEndTime - buildStartTime ); - aacircleRGBA( screen, x, y, (int)( size + 102.5 - percentage ), 0xff, 0xff, 0xff, (int)( 0.2 * percentage ) ); + Canvas::drawBuildProgress(location, size, percentage); } void @@ -213,8 +215,13 @@ } void +Planet::setNearestPlanet(bool b) { + nearestPlanet = b; +} + +void Planet::setSourceSelected( bool selected ) { - this->sourceSelected = selected; + sourceSelected = selected; } void Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.h 2007-04-05 01:04:12 UTC (rev 21) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.h 2007-04-05 01:44:29 UTC (rev 22) @@ -53,7 +53,7 @@ void setSourceSelected( bool selected ); bool isSourceSelected() { return sourceSelected; } - void setNearestPlanet(bool b) { nearestPlanet = b; } + void setNearestPlanet(bool b); bool isNearestPlanet() { return nearestPlanet; } void setSelected( bool selected ); Modified: branches/autoconf-2007-03-26-thebohemian/src/players.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-05 01:04:12 UTC (rev 21) +++ branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-05 01:44:29 UTC (rev 22) @@ -76,7 +76,7 @@ if( i->getOwner() == this ) { int size = 3; if( i->getMoon() ) size = 2; - Canvas::drawPlanetMapped( screen, counter, height + 5, size, color ); + Canvas::drawPlanetMapped(counter, height + 5, size, color ); counter+= size * 2 + 3; } } Modified: branches/autoconf-2007-03-26-thebohemian/src/ships.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-05 01:04:12 UTC (rev 21) +++ branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-05 01:44:29 UTC (rev 22) @@ -96,9 +96,9 @@ Coordinate loc = getLocation(); if( shipState == RESIDENT ) { Coordinate planetLocation = planet->getLocation(); - Canvas::drawResidentShip(screen, loc, planetLocation, color); + Canvas::drawResidentShip(loc, planetLocation, color); } else { - Canvas::drawFlyingShip(screen, loc, getDirection(), color); + Canvas::drawFlyingShip(loc, getDirection(), color); } } @@ -106,7 +106,7 @@ Ship::renderSelection( SDL_Surface* screen ) const { Coordinate loc = getLocation(); if( selected ) - Canvas::drawSelection(screen, loc); + Canvas::drawSelection(loc); } double Modified: branches/autoconf-2007-03-26-thebohemian/src/universe.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-05 01:04:12 UTC (rev 21) +++ branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-05 01:44:29 UTC (rev 22) @@ -13,7 +13,7 @@ #include "settings.h" #include "canvas.h" -Universe::Universe() { +Universe::Universe() : currentSelectedPlanet(0) { stars = new Stars( 100 ); planets = new Planets( 15, 15 ); planets->setUniverse( this ); @@ -22,7 +22,7 @@ messages = new Messages(); } -Universe::Universe( int nrPlanets ) { +Universe::Universe( int nrPlanets ) : currentSelectedPlanet(0) { stars = new Stars( 100 ); planets = new Planets( nrPlanets, nrPlanets ); planets->setUniverse( this ); @@ -83,7 +83,9 @@ currentSelectedPlanet->setNearestPlanet(false); currentSelectedPlanet = closestPlanet; - currentSelectedPlanet->setNearestPlanet(true); + + if (currentSelectedPlanet) + currentSelectedPlanet->setNearestPlanet(true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-05 01:04:20
|
Revision: 21 http://qonk.svn.sourceforge.net/qonk/?rev=21&view=rev Author: thebohemian Date: 2007-04-04 18:04:12 -0700 (Wed, 04 Apr 2007) Log Message: ----------- - moved display initialization into Canvas - moved SDL_Surface variable into Canvas - started to remove SDL_Surface as parameter usage Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp branches/autoconf-2007-03-26-thebohemian/src/canvas.h branches/autoconf-2007-03-26-thebohemian/src/main.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.h branches/autoconf-2007-03-26-thebohemian/src/universe.cpp Modified: branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp 2007-04-05 00:17:27 UTC (rev 20) +++ branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp 2007-04-05 01:04:12 UTC (rev 21) @@ -1,11 +1,16 @@ -// Copyright 2005 by Anthony Liekens an...@li... +// Copyright 2005 by Anthony Liekens <an...@li...> +// Copyright 2007 by Robert Schuster <rob...@fs...> + #include <SDL/SDL_gfxPrimitives.h> #include "canvas.h" #include "extensions.h" #include "coordinate.h" +#include "settings.h" +SDL_Surface* Canvas::main = 0; + void Canvas::alphaBlend( SDL_Surface* surface, Uint8 alpha ) { if( alpha == 0 ) { @@ -31,29 +36,31 @@ } void -Canvas::drawSelector(SDL_Surface *screen, - Coordinate &c, Sint16 offset, +Canvas::drawSelector(Coordinate &c, Sint16 offset, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B) { - drawSelectorImpl(screen, c.getXMapped() + offset, c.getYMapped() + offset, width, height, R, G, B); + int x1 = c.getXMapped() + offset; + int y1 = c.getYMapped() + offset; + + hlineRGBA( main, x1, x1 + 2, y1, R, G, B, 255 ); + hlineRGBA( main, x1 + width - 2, x1 + width, y1, R, G, B, 255 ); + hlineRGBA( main, x1, x1 + 2, y1 + height, R, G, B, 255 ); + hlineRGBA( main, x1 + width - 2, x1 + width, y1 + height, R, G, B, 255 ); + vlineRGBA( main, x1, y1, y1 + 2, R, G, B, 255 ); + vlineRGBA( main, x1, y1 + height, y1 + height - 2, R, G, B, 255 ); + vlineRGBA( main, x1 + width, y1, y1 + 2, R, G, B, 255 ); + vlineRGBA( main, x1 + width, y1 + height, y1 + height - 2, R, G, B, 255 ); } void -Canvas::drawSelectorImpl( SDL_Surface *screen, Sint16 x1, Sint16 y1, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ) +Canvas::drawNearestPlanetSelector(Coordinate &c) { - hlineRGBA( screen, x1, x1 + 2, y1, R, G, B, 255 ); - hlineRGBA( screen, x1 + width - 2, x1 + width, y1, R, G, B, 255 ); - hlineRGBA( screen, x1, x1 + 2, y1 + height, R, G, B, 255 ); - hlineRGBA( screen, x1 + width - 2, x1 + width, y1 + height, R, G, B, 255 ); - vlineRGBA( screen, x1, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( screen, x1, y1 + height, y1 + height - 2, R, G, B, 255 ); - vlineRGBA( screen, x1 + width, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( screen, x1 + width, y1 + height, y1 + height - 2, R, G, B, 255 ); + drawSelector(c, -5, 10, 10, 255, 0, 0); } void -Canvas::drawPlanet( SDL_Surface* screen, Coordinate &loc, int size, Uint32 color ) { - drawPlanetMapped(screen, loc.getXMapped(), loc.getYMapped(), size, color); +Canvas::drawPlanet( Coordinate &loc, int size, Uint32 color ) { + drawPlanetMapped(main, loc.getXMapped(), loc.getYMapped(), size, color); } void @@ -117,3 +124,27 @@ { aacircleRGBA(screen, location.getXMapped(), location.getYMapped(), 3, 255, 192, 0, 255 ); } + +void +Canvas::drawOrbit(Coordinate ¢er, double rotationDistance, int color) +{ + int r = getRed(color); + int g = getGreen(color); + int b = getBlue(color); + + aaellipseRGBA(main, center.getXMapped(), center.getYMapped(), + (int) (rotationDistance * Settings::getGameWidth()), + (int) (rotationDistance * Settings::getGameHeight()), + r, g, b, 64); +} + +SDL_Surface * +Canvas::initScreen() +{ + long flags = SDL_SWSURFACE; + if (Settings::getFullscreen()) + flags |= SDL_FULLSCREEN; + + return main = SDL_SetVideoMode( Settings::getScreenWidth(), Settings::getScreenHeight(), 32, flags); +} + Modified: branches/autoconf-2007-03-26-thebohemian/src/canvas.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/canvas.h 2007-04-05 00:17:27 UTC (rev 20) +++ branches/autoconf-2007-03-26-thebohemian/src/canvas.h 2007-04-05 01:04:12 UTC (rev 21) @@ -17,13 +17,14 @@ public: static void alphaBlend( SDL_Surface* surface, Uint8 alpha ); - static void drawSelector( SDL_Surface *screen, - Coordinate&, Sint16 offset, + static void drawSelector( Coordinate&, Sint16 offset, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ); - static void drawPlanet(SDL_Surface* screen, Coordinate&, int size, Uint32 color); + static void drawNearestPlanetSelector(Coordinate&); + static void drawPlanet(Coordinate&, int size, Uint32 color); + static void drawPlanetMapped(SDL_Surface* screen, int x, int y, int size, Uint32 color); static void drawResidentShip(SDL_Surface* screen, Coordinate& shipLocation, Coordinate& planetLocation, @@ -33,11 +34,14 @@ static void drawSelection(SDL_Surface *screen, Coordinate&); + static void drawOrbit(Coordinate&, double rotationDistance, int color); + + static SDL_Surface *initScreen(); + private: - static void drawSelectorImpl(SDL_Surface *screen, - Sint16 x1, Sint16 y1, Sint16 width, - Sint16 height, Uint8 R, Uint8 G, Uint8 B); + static SDL_Surface* main; + }; #endif /* CANVAS_H */ Modified: branches/autoconf-2007-03-26-thebohemian/src/main.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/main.cpp 2007-04-05 00:17:27 UTC (rev 20) +++ branches/autoconf-2007-03-26-thebohemian/src/main.cpp 2007-04-05 01:04:12 UTC (rev 21) @@ -13,6 +13,7 @@ #include "settings.h" #include "extensions.h" #include "messages.h" +#include "canvas.h" #include <math.h> @@ -56,17 +57,6 @@ } -void changeScreen(SDL_Surface **screen) { - long flags = SDL_SWSURFACE; - if (Settings::getFullscreen()) - { - flags |= SDL_FULLSCREEN; - } - - *screen = SDL_SetVideoMode( Settings::getScreenWidth(), Settings::getScreenHeight(), 32, flags); -} - - int main(int argc, char** argv) { bool FirstRun = true; @@ -140,10 +130,8 @@ SDL_WM_SetCaption( "Qonk", "Qonk" ); /* Initialize the display */ - SDL_Surface *screen; + SDL_Surface *screen = Canvas::initScreen(); - changeScreen(&screen); - Universe* universe = new Universe( numberOfPlanets ); Players* players = new Players( universe ); @@ -225,7 +213,7 @@ } if(event.key.keysym.sym == SDLK_f){ Settings::setFullscreen(!Settings::getFullscreen()); - changeScreen(&screen); + screen = Canvas::initScreen(); } break; case SDL_QUIT: Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-05 00:17:27 UTC (rev 20) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-05 01:04:12 UTC (rev 21) @@ -58,6 +58,7 @@ motherLocation.setX( 0.5 ); motherLocation.setY( 0.5 ); } + Coordinate v = getVector( time ); double x = motherLocation.getX() + rotationDistance * v.getX(); double y = motherLocation.getY() + rotationDistance * v.getY(); @@ -144,12 +145,23 @@ renderBuildProgress( screen ); Coordinate location = getLocation(); - Canvas::drawPlanet( screen, location, size, owner->getColor() ); + Canvas::drawPlanet(location, size, owner->getColor() ); if( selected ) - renderSelector( screen ); + { + Canvas::drawSelector(location, -4, 10, 10, 0, 0, 0); + Canvas::drawSelector(location, -5, 10, 10, 255, 192, 0); + } if( sourceSelected ) - renderSourceSelector( screen ); + { + Canvas::drawSelector(location, -4, 10, 10, 0, 0, 0); + Canvas::drawSelector(location, -5, 10, 10, 255, 255, 0); + } + + if (nearestPlanet) + { + Canvas::drawNearestPlanetSelector(location); + } } void @@ -162,31 +174,13 @@ centerLocation.setY( 0.5 ); } if( owner != NULL ) - aaellipseRGBA( screen, centerLocation.getXMapped(), centerLocation.getYMapped(), - (int)( rotationDistance * Settings::getGameWidth() ), - (int)( rotationDistance * Settings::getGameHeight() ), - getRed( owner->getColor() ), getGreen( owner->getColor() ), - getBlue( owner->getColor() ), 64 ); + Canvas::drawOrbit(centerLocation, rotationDistance, owner->getColor()); if( getMoon() ) { mother->renderOrbit( screen ); } } void -Planet::renderSelector( SDL_Surface* screen ) const { - Coordinate location = getLocation(); - Canvas::drawSelector(screen, location, -4, 10, 10, 0, 0, 0); - Canvas::drawSelector(screen, location, -5, 10, 10, 255, 192, 0); -} - -void -Planet::renderSourceSelector( SDL_Surface* screen ) const { - Coordinate location = getLocation(); - Canvas::drawSelector(screen, location, -4, 10, 10, 0, 0, 0); - Canvas::drawSelector(screen, location, -5, 10, 10, 255, 255, 0); -} - -void Planet::renderBuildProgress( SDL_Surface* screen ) const { Coordinate location = getLocation(); Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.h 2007-04-05 00:17:27 UTC (rev 20) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.h 2007-04-05 01:04:12 UTC (rev 21) @@ -25,7 +25,7 @@ double rotationDistance; int shipCreationSpeed; int size; - bool isAMoon, selected, sourceSelected; + bool isAMoon, selected, sourceSelected, nearestPlanet; Planet* mother; list< Ship* > residentShips; Uint32 buildStartTime, buildEndTime; @@ -43,8 +43,6 @@ void render( SDL_Surface* screen ) const; void renderOrbit( SDL_Surface* screen ) const; - void renderSelector( SDL_Surface* screen ) const; - void renderSourceSelector( SDL_Surface* screen ) const; void renderBuildProgress( SDL_Surface* screen ) const; void updateShipLocations(); @@ -54,6 +52,9 @@ int numberOfResidentShips() { return residentShips.size(); } void setSourceSelected( bool selected ); bool isSourceSelected() { return sourceSelected; } + + void setNearestPlanet(bool b) { nearestPlanet = b; } + bool isNearestPlanet() { return nearestPlanet; } void setSelected( bool selected ); void setUniverse( Universe* universe ); Modified: branches/autoconf-2007-03-26-thebohemian/src/universe.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-05 00:17:27 UTC (rev 20) +++ branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-05 01:04:12 UTC (rev 21) @@ -11,6 +11,7 @@ #include "animations.h" #include "timer.h" #include "settings.h" +#include "canvas.h" Universe::Universe() { stars = new Stars( 100 ); @@ -78,11 +79,11 @@ if( !( mouseState & SDL_BUTTON(1) ) ) { -// if( closestPlanet != NULL ) { -// closestPlanet->renderOrbit( screen ); -// } + if (currentSelectedPlanet) + currentSelectedPlanet->setNearestPlanet(false); currentSelectedPlanet = closestPlanet; + currentSelectedPlanet->setNearestPlanet(true); } @@ -115,9 +116,4 @@ planets->updateShipLocations(); planets->render( screen ); - if( currentSelectedPlanet != NULL ) { - currentSelectedPlanet->renderSelector( screen ); - } - } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-05 00:17:29
|
Revision: 20 http://qonk.svn.sourceforge.net/qonk/?rev=20&view=rev Author: thebohemian Date: 2007-04-04 17:17:27 -0700 (Wed, 04 Apr 2007) Log Message: ----------- - moved some drawing operations from extensions.h into its own class - added drawing operations from planets.cpp to canvas Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/src/Makefile.am branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp branches/autoconf-2007-03-26-thebohemian/src/extensions.h branches/autoconf-2007-03-26-thebohemian/src/fonts.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.cpp branches/autoconf-2007-03-26-thebohemian/src/players.cpp branches/autoconf-2007-03-26-thebohemian/src/ships.cpp Added Paths: ----------- branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp branches/autoconf-2007-03-26-thebohemian/src/canvas.h Modified: branches/autoconf-2007-03-26-thebohemian/src/Makefile.am =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/Makefile.am 2007-04-04 22:58:18 UTC (rev 19) +++ branches/autoconf-2007-03-26-thebohemian/src/Makefile.am 2007-04-05 00:17:27 UTC (rev 20) @@ -7,6 +7,8 @@ actions.h \ animations.cpp \ animations.h \ + canvas.cpp \ + canvas.h \ coordinate.cpp \ coordinate.h \ extensions.cpp \ Copied: branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp (from rev 14, branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp) =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/src/canvas.cpp 2007-04-05 00:17:27 UTC (rev 20) @@ -0,0 +1,119 @@ +// Copyright 2005 by Anthony Liekens an...@li... +#include <SDL/SDL_gfxPrimitives.h> + +#include "canvas.h" + +#include "extensions.h" +#include "coordinate.h" + +void +Canvas::alphaBlend( SDL_Surface* surface, Uint8 alpha ) { + if( alpha == 0 ) { + for( int x = 0; x < surface->w; x++ ) + for( int y = 0; y < surface->h; y++ ) { + Uint32 *bufp; + bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; + if( *bufp != 0 ) + *bufp &= 0x00ffffff; + } + } if( alpha != 255 ) { + for( int x = 0; x < surface->w; x++ ) + for( int y = 0; y < surface->h; y++ ) { + Uint32 *bufp; + bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; + if( *bufp != 0 ) { + // seperate RGB from A, update A for new value, OR them together again + Uint32 color = ( *bufp & 0x00ffffff ) | ( ( *bufp >> 24 ) * alpha >> 8 ) << 24; + *bufp = color; + } + } + } +} + +void +Canvas::drawSelector(SDL_Surface *screen, + Coordinate &c, Sint16 offset, + Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B) +{ + drawSelectorImpl(screen, c.getXMapped() + offset, c.getYMapped() + offset, width, height, R, G, B); +} + +void +Canvas::drawSelectorImpl( SDL_Surface *screen, Sint16 x1, Sint16 y1, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ) +{ + hlineRGBA( screen, x1, x1 + 2, y1, R, G, B, 255 ); + hlineRGBA( screen, x1 + width - 2, x1 + width, y1, R, G, B, 255 ); + hlineRGBA( screen, x1, x1 + 2, y1 + height, R, G, B, 255 ); + hlineRGBA( screen, x1 + width - 2, x1 + width, y1 + height, R, G, B, 255 ); + vlineRGBA( screen, x1, y1, y1 + 2, R, G, B, 255 ); + vlineRGBA( screen, x1, y1 + height, y1 + height - 2, R, G, B, 255 ); + vlineRGBA( screen, x1 + width, y1, y1 + 2, R, G, B, 255 ); + vlineRGBA( screen, x1 + width, y1 + height, y1 + height - 2, R, G, B, 255 ); +} + +void +Canvas::drawPlanet( SDL_Surface* screen, Coordinate &loc, int size, Uint32 color ) { + drawPlanetMapped(screen, loc.getXMapped(), loc.getYMapped(), size, color); +} + +void +Canvas::drawPlanetMapped( SDL_Surface* screen, int x, int y, int size, Uint32 color ) { + int R = getRed(color); + int G = getGreen(color); + int B = getBlue(color); + + filledCircleRGBA( screen, x, y, size + 2, 0, 0, 0, 128 ); + filledCircleRGBA( screen, x, y, size, R, G, B, 255 ); + aacircleRGBA( screen, x, y, size, R, G, B, 255 ); + filledEllipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); + aaellipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); +} + +void +Canvas::drawResidentShip(SDL_Surface* screen, Coordinate& shipLocation, Coordinate& planetLocation, + int color) { + int sx = shipLocation.getXMapped(); + int sy = shipLocation.getYMapped(); + + int px = planetLocation.getXMapped(); + int py = planetLocation.getYMapped(); + + int r = getRed(color); + int g = getGreen(color); + int b = getBlue(color); + + aalineRGBA( screen, sx, sy, px, py, r, g, b, 64 ); + filledCircleRGBA( screen, sx, sy, 1, r, g, b, 255 ); +} + +void +Canvas::drawFlyingShip(SDL_Surface *screen, Coordinate& shipLocation, double direction, int color) +{ + int sx = shipLocation.getXMapped(); + int sy = shipLocation.getYMapped(); + + int r = getRed(color); + int g = getGreen(color); + int b = getBlue(color); + + int headX, headY; + int leftTipX, leftTipY; + int rightTipX, rightTipY; + + headX = (int) (sx + 5.0 * cos( direction)); + headY = (int) (sy + 5.0 * sin( direction)); + leftTipX = (int) (sx + 2.0 * cos( direction + M_PI / 3.0)); + leftTipY = (int) (sy + 2.0 * sin( direction + M_PI / 3.0)); + rightTipX = (int) (sx + 2.0 * cos( direction - M_PI / 3.0)); + rightTipY = (int) (sy + 2.0 * sin( direction - M_PI / 3.0)); + + aalineRGBA(screen, leftTipX, leftTipY, headX, headY, r, g, b, 255); + aalineRGBA(screen, rightTipX, rightTipY, headX, headY, r, g, b, 255); + aalineRGBA(screen, rightTipX, rightTipY, leftTipX, leftTipY, r, g, b, 255); +} + +void +Canvas::drawSelection(SDL_Surface *screen, Coordinate& location) +{ + aacircleRGBA(screen, location.getXMapped(), location.getYMapped(), 3, 255, 192, 0, 255 ); +} Copied: branches/autoconf-2007-03-26-thebohemian/src/canvas.h (from rev 14, branches/autoconf-2007-03-26-thebohemian/src/extensions.h) =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/canvas.h (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/src/canvas.h 2007-04-05 00:17:27 UTC (rev 20) @@ -0,0 +1,43 @@ +// Copyright 2007 by Robert Schuster <rob...@fs...> + +// Basic drawing and converting operations for Qonk + +// If not explicitly told otherwise coordinate values are +// in game units. + +#ifndef CANVAS_H +#define CANVAS_H + +#include <SDL/SDL.h> + +class Coordinate; + +class Canvas +{ + public: + static void alphaBlend( SDL_Surface* surface, Uint8 alpha ); + + static void drawSelector( SDL_Surface *screen, + Coordinate&, Sint16 offset, + Sint16 width, Sint16 height, + Uint8 R, Uint8 G, Uint8 B ); + + static void drawPlanet(SDL_Surface* screen, Coordinate&, int size, Uint32 color); + + static void drawPlanetMapped(SDL_Surface* screen, int x, int y, int size, Uint32 color); + + static void drawResidentShip(SDL_Surface* screen, Coordinate& shipLocation, Coordinate& planetLocation, + int color); + + static void drawFlyingShip(SDL_Surface *screen, Coordinate&, double direction, int color); + + static void drawSelection(SDL_Surface *screen, Coordinate&); + + private: + static void drawSelectorImpl(SDL_Surface *screen, + Sint16 x1, Sint16 y1, Sint16 width, + Sint16 height, Uint8 R, Uint8 G, Uint8 B); + +}; + +#endif /* CANVAS_H */ Modified: branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp 2007-04-04 22:58:18 UTC (rev 19) +++ branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp 2007-04-05 00:17:27 UTC (rev 20) @@ -3,56 +3,6 @@ #include "extensions.h" -void -alphaBlend( SDL_Surface* surface, Uint8 alpha ) { - if( alpha == 0 ) { - for( int x = 0; x < surface->w; x++ ) - for( int y = 0; y < surface->h; y++ ) { - Uint32 *bufp; - bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; - if( *bufp != 0 ) - *bufp &= 0x00ffffff; - } - } if( alpha != 255 ) { - for( int x = 0; x < surface->w; x++ ) - for( int y = 0; y < surface->h; y++ ) { - Uint32 *bufp; - bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; - if( *bufp != 0 ) { - // seperate RGB from A, update A for new value, OR them together again - Uint32 color = ( *bufp & 0x00ffffff ) | ( ( *bufp >> 24 ) * alpha >> 8 ) << 24; - *bufp = color; - } - } - } -} - -void -drawSelector( SDL_Surface *screen, Sint16 x1, Sint16 y1, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ) { - hlineRGBA( screen, x1, x1 + 2, y1, R, G, B, 255 ); - hlineRGBA( screen, x1 + width - 2, x1 + width, y1, R, G, B, 255 ); - hlineRGBA( screen, x1, x1 + 2, y1 + height, R, G, B, 255 ); - hlineRGBA( screen, x1 + width - 2, x1 + width, y1 + height, R, G, B, 255 ); - vlineRGBA( screen, x1, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( screen, x1, y1 + height, y1 + height - 2, R, G, B, 255 ); - vlineRGBA( screen, x1 + width, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( screen, x1 + width, y1 + height, y1 + height - 2, R, G, B, 255 ); -} - -void -drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint8 R, Uint8 G, Uint8 B ) { - filledCircleRGBA( screen, x, y, size + 2, 0, 0, 0, 128 ); - filledCircleRGBA( screen, x, y, size, R, G, B, 255 ); - aacircleRGBA( screen, x, y, size, R, G, B, 255 ); - filledEllipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); - aaellipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); -} - -void -drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint32 color ) { - drawPlanet( screen, x, y, size, getRed( color ), getGreen( color ), getBlue( color ) ); -} - double frand() { return (double)rand() / RAND_MAX; Modified: branches/autoconf-2007-03-26-thebohemian/src/extensions.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/extensions.h 2007-04-04 22:58:18 UTC (rev 19) +++ branches/autoconf-2007-03-26-thebohemian/src/extensions.h 2007-04-05 00:17:27 UTC (rev 20) @@ -5,11 +5,6 @@ #include <SDL/SDL.h> -void alphaBlend( SDL_Surface* surface, Uint8 alpha ); - -void drawSelector( SDL_Surface *screen, Sint16 x1, Sint16 y1, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ); -void drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint8 R, Uint8 G, Uint8 B ); -void drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint32 color ); double frand(); double frand( double max ); Uint32 HSVtoRGB( float h, float s, float v ); Modified: branches/autoconf-2007-03-26-thebohemian/src/fonts.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/fonts.cpp 2007-04-04 22:58:18 UTC (rev 19) +++ branches/autoconf-2007-03-26-thebohemian/src/fonts.cpp 2007-04-05 00:17:27 UTC (rev 20) @@ -2,7 +2,7 @@ #include "fonts.h" -#include "extensions.h" +#include "canvas.h" Font::Font( char* fileName, int size ) { font = TTF_OpenFont( fileName, size ); @@ -23,7 +23,7 @@ dstrect.y = y; dstrect.w = textSurface->w; dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); + Canvas::alphaBlend( textSurface, a ); SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); SDL_FreeSurface( textSurface ); } @@ -39,7 +39,7 @@ dstrect.y = y - textSurface->h / 2; dstrect.w = textSurface->w; dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); + Canvas::alphaBlend( textSurface, a ); SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); SDL_FreeSurface( textSurface ); } @@ -55,7 +55,7 @@ dstrect.y = y; dstrect.w = textSurface->w; dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); + Canvas::alphaBlend( textSurface, a ); SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); SDL_FreeSurface( textSurface ); } Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-04 22:58:18 UTC (rev 19) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-05 00:17:27 UTC (rev 20) @@ -14,6 +14,7 @@ #include "universe.h" #include "fonts.h" #include "messages.h" +#include "canvas.h" // ##### PLANET ##### @@ -142,9 +143,8 @@ if( owner->getPlayerType() == Player::HUMAN ) renderBuildProgress( screen ); Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawPlanet( screen, x, y, size, owner->getColor() ); + + Canvas::drawPlanet( screen, location, size, owner->getColor() ); if( selected ) renderSelector( screen ); @@ -175,25 +175,20 @@ void Planet::renderSelector( SDL_Surface* screen ) const { Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawSelector( screen, x - 4, y - 4, 10, 10, 0, 0, 0 ); - drawSelector( screen, x - 5, y - 5, 10, 10, 255, 192, 0 ); + Canvas::drawSelector(screen, location, -4, 10, 10, 0, 0, 0); + Canvas::drawSelector(screen, location, -5, 10, 10, 255, 192, 0); } void Planet::renderSourceSelector( SDL_Surface* screen ) const { Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawSelector( screen, x - 4, y - 4, 10, 10, 0, 0, 0 ); - drawSelector( screen, x - 5, y - 5, 10, 10, 255, 255, 255 ); + Canvas::drawSelector(screen, location, -4, 10, 10, 0, 0, 0); + Canvas::drawSelector(screen, location, -5, 10, 10, 255, 255, 0); } void Planet::renderBuildProgress( SDL_Surface* screen ) const { - Coordinate location = getLocation(); Font* font = universe->messages->getFont(); int x = location.getXMapped(); Modified: branches/autoconf-2007-03-26-thebohemian/src/players.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-04 22:58:18 UTC (rev 19) +++ branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-05 00:17:27 UTC (rev 20) @@ -13,6 +13,7 @@ #include "settings.h" #include "selection.h" #include "messages.h" +#include "canvas.h" // ##### PLAYER ##### @@ -75,7 +76,7 @@ if( i->getOwner() == this ) { int size = 3; if( i->getMoon() ) size = 2; - drawPlanet( screen, counter, height + 5, size, color ); + Canvas::drawPlanetMapped( screen, counter, height + 5, size, color ); counter+= size * 2 + 3; } } Modified: branches/autoconf-2007-03-26-thebohemian/src/ships.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-04 22:58:18 UTC (rev 19) +++ branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-05 00:17:27 UTC (rev 20) @@ -1,13 +1,16 @@ // Copyright 2005 by Anthony Liekens an...@li... + #include <iostream> +#include "math.h" -#include <SDL/SDL_gfxPrimitives.h> +#include <SDL/SDL.h> #include "coordinate.h" #include "planets.h" #include "timer.h" #include "extensions.h" #include "selection.h" +#include "canvas.h" #include "ships.h" @@ -91,23 +94,11 @@ void Ship::render( SDL_Surface* screen, Uint32 color ) const { Coordinate loc = getLocation(); - int locx = loc.getXMapped(); - int locy = loc.getYMapped(); - int red = getRed( color ); - int green = getGreen( color ); - int blue = getBlue( color ); if( shipState == RESIDENT ) { Coordinate planetLocation = planet->getLocation(); - aalineRGBA( screen, locx, locy, planetLocation.getXMapped(), planetLocation.getYMapped(), red, green, blue, 64 ); - filledCircleRGBA( screen, locx, locy, 1, getRed( color ), getGreen( color ), getBlue( color ), 255 ); + Canvas::drawResidentShip(screen, loc, planetLocation, color); } else { - double direction = getDirection(); - Coordinate head = Coordinate( locx + 5.0 * cos( direction ), locy + 5.0 * sin( direction ) ); - Coordinate leftTip = Coordinate( locx + 2.0 * cos( direction + M_PI / 3.0 ), locy + 2.0 * sin( direction + M_PI / 3.0 ) ); - Coordinate rightTip = Coordinate( locx + 2.0 * cos( direction - M_PI / 3.0 ), locy + 2.0 * sin( direction - M_PI / 3.0 ) ); - aalineRGBA( screen, leftTip.getX(), leftTip.getY(), head.getX(), head.getY(), red, green, blue, 255 ); - aalineRGBA( screen, rightTip.getX(), rightTip.getY(), head.getX(), head.getY(), red, green, blue, 255 ); - aalineRGBA( screen, rightTip.getX(), rightTip.getY(), leftTip.getX(), leftTip.getY(), red, green, blue, 255 ); + Canvas::drawFlyingShip(screen, loc, getDirection(), color); } } @@ -115,8 +106,7 @@ Ship::renderSelection( SDL_Surface* screen ) const { Coordinate loc = getLocation(); if( selected ) - aacircleRGBA( screen, loc.getXMapped(), loc.getYMapped(), 3, 255, 192, 0, 255 ); -// aacircleRGBA( screen, loc.getXMapped(), loc.getYMapped(), 2, 0, 0, 0, 255 ); + Canvas::drawSelection(screen, loc); } double This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-04 22:58:19
|
Revision: 19 http://qonk.svn.sourceforge.net/qonk/?rev=19&view=rev Author: thebohemian Date: 2007-04-04 15:58:18 -0700 (Wed, 04 Apr 2007) Log Message: ----------- - unknoting headers part 2 Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/src/main.cpp branches/autoconf-2007-03-26-thebohemian/src/messages.cpp branches/autoconf-2007-03-26-thebohemian/src/messages.h branches/autoconf-2007-03-26-thebohemian/src/planets.cpp branches/autoconf-2007-03-26-thebohemian/src/players.cpp branches/autoconf-2007-03-26-thebohemian/src/players.h branches/autoconf-2007-03-26-thebohemian/src/selection.cpp branches/autoconf-2007-03-26-thebohemian/src/selection.h branches/autoconf-2007-03-26-thebohemian/src/ships.cpp branches/autoconf-2007-03-26-thebohemian/src/stars.cpp branches/autoconf-2007-03-26-thebohemian/src/stars.h Modified: branches/autoconf-2007-03-26-thebohemian/src/main.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/main.cpp 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/main.cpp 2007-04-04 22:58:18 UTC (rev 19) @@ -12,6 +12,7 @@ #include "fonts.h" #include "settings.h" #include "extensions.h" +#include "messages.h" #include <math.h> Modified: branches/autoconf-2007-03-26-thebohemian/src/messages.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/messages.cpp 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/messages.cpp 2007-04-04 22:58:18 UTC (rev 19) @@ -6,6 +6,7 @@ #include "coordinate.h" #include "extensions.h" #include "universe.h" +#include "fonts.h" Message::Message( string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ) { Modified: branches/autoconf-2007-03-26-thebohemian/src/messages.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/messages.h 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/messages.h 2007-04-04 22:58:18 UTC (rev 19) @@ -3,13 +3,15 @@ #ifndef MESSAGES_H #define MESSAGES_H +#include <string> #include <map> #include <SDL/SDL.h> -#include "fonts.h" +using namespace std; class Universe; +class Font; class Message { private: Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-04 22:58:18 UTC (rev 19) @@ -12,6 +12,8 @@ #include "selection.h" #include "players.h" #include "universe.h" +#include "fonts.h" +#include "messages.h" // ##### PLANET ##### Modified: branches/autoconf-2007-03-26-thebohemian/src/players.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-04 22:58:18 UTC (rev 19) @@ -11,6 +11,8 @@ #include "extensions.h" #include "timer.h" #include "settings.h" +#include "selection.h" +#include "messages.h" // ##### PLAYER ##### Modified: branches/autoconf-2007-03-26-thebohemian/src/players.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/players.h 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/players.h 2007-04-04 22:58:18 UTC (rev 19) @@ -8,12 +8,11 @@ using namespace std; #include "actions.h" -#include "messages.h" -#include "selection.h" class Ships; class Universe; class Planet; +class Selection; class Player { public: Modified: branches/autoconf-2007-03-26-thebohemian/src/selection.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/selection.cpp 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/selection.cpp 2007-04-04 22:58:18 UTC (rev 19) @@ -3,6 +3,7 @@ #include <SDL/SDL_gfxPrimitives.h> +#include "coordinate.h" #include "selection.h" Selection::Selection() { Modified: branches/autoconf-2007-03-26-thebohemian/src/selection.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/selection.h 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/selection.h 2007-04-04 22:58:18 UTC (rev 19) @@ -3,10 +3,10 @@ #ifndef SELECTION_H #define SELECTION_H -#include "coordinate.h" - #include <SDL/SDL.h> +class Coordinate; + class Selection { private: Coordinate c1, c2; Modified: branches/autoconf-2007-03-26-thebohemian/src/ships.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-04 22:58:18 UTC (rev 19) @@ -4,12 +4,13 @@ #include <SDL/SDL_gfxPrimitives.h> #include "coordinate.h" -#include "ships.h" #include "planets.h" #include "timer.h" #include "extensions.h" #include "selection.h" +#include "ships.h" + /* ##### SHIP ##### */ Ship::Ship( Player* owner, Planet* planet ) { Modified: branches/autoconf-2007-03-26-thebohemian/src/stars.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/stars.cpp 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/stars.cpp 2007-04-04 22:58:18 UTC (rev 19) @@ -2,6 +2,7 @@ #include <SDL/SDL_gfxPrimitives.h> +#include "coordinate.h" #include "stars.h" // ##### STAR METHODS ##### Modified: branches/autoconf-2007-03-26-thebohemian/src/stars.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/stars.h 2007-04-04 22:46:47 UTC (rev 18) +++ branches/autoconf-2007-03-26-thebohemian/src/stars.h 2007-04-04 22:58:18 UTC (rev 19) @@ -11,8 +11,8 @@ class Star { private: + Uint8 brightness; Coordinate c; - Uint8 brightness; public: Star(); void render( SDL_Surface* screen ) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-04 22:46:49
|
Revision: 18 http://qonk.svn.sourceforge.net/qonk/?rev=18&view=rev Author: thebohemian Date: 2007-04-04 15:46:47 -0700 (Wed, 04 Apr 2007) Log Message: ----------- - started to unknot the header dependencies Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/src/animations.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.h branches/autoconf-2007-03-26-thebohemian/src/ships.cpp branches/autoconf-2007-03-26-thebohemian/src/ships.h branches/autoconf-2007-03-26-thebohemian/src/universe.cpp branches/autoconf-2007-03-26-thebohemian/src/universe.h Modified: branches/autoconf-2007-03-26-thebohemian/src/animations.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/animations.cpp 2007-04-04 22:01:00 UTC (rev 17) +++ branches/autoconf-2007-03-26-thebohemian/src/animations.cpp 2007-04-04 22:46:47 UTC (rev 18) @@ -5,6 +5,7 @@ #include "animations.h" #include "timer.h" #include "planets.h" +#include "coordinate.h" void Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-04 22:01:00 UTC (rev 17) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-04 22:46:47 UTC (rev 18) @@ -7,6 +7,11 @@ #include "ships.h" #include "extensions.h" #include "settings.h" +#include "animations.h" +#include "coordinate.h" +#include "selection.h" +#include "players.h" +#include "universe.h" // ##### PLANET ##### Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.h 2007-04-04 22:01:00 UTC (rev 17) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.h 2007-04-04 22:46:47 UTC (rev 18) @@ -7,14 +7,15 @@ #include <SDL/SDL.h> -#include "coordinate.h" -#include "players.h" #include "actions.h" -#include "universe.h" using namespace std; class Ship; +class Universe; +class Player; +class Coordinate; +class Selection; class Planet { private: Modified: branches/autoconf-2007-03-26-thebohemian/src/ships.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-04 22:01:00 UTC (rev 17) +++ branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-04 22:46:47 UTC (rev 18) @@ -3,9 +3,12 @@ #include <SDL/SDL_gfxPrimitives.h> +#include "coordinate.h" #include "ships.h" +#include "planets.h" +#include "timer.h" #include "extensions.h" -#include "timer.h" +#include "selection.h" /* ##### SHIP ##### */ Modified: branches/autoconf-2007-03-26-thebohemian/src/ships.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ships.h 2007-04-04 22:01:00 UTC (rev 17) +++ branches/autoconf-2007-03-26-thebohemian/src/ships.h 2007-04-04 22:46:47 UTC (rev 18) @@ -8,14 +8,12 @@ #include <SDL/SDL.h> -#include "coordinate.h" -#include "players.h" -#include "planets.h" #include "actions.h" -#include "selection.h" +#include "coordinate.h" class Planet; class Player; +class Selection; class Ship { public: Modified: branches/autoconf-2007-03-26-thebohemian/src/universe.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-04 22:01:00 UTC (rev 17) +++ branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-04 22:46:47 UTC (rev 18) @@ -8,6 +8,7 @@ #include "stars.h" #include "messages.h" #include "actions.h" +#include "animations.h" #include "timer.h" #include "settings.h" Modified: branches/autoconf-2007-03-26-thebohemian/src/universe.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/universe.h 2007-04-04 22:01:00 UTC (rev 17) +++ branches/autoconf-2007-03-26-thebohemian/src/universe.h 2007-04-04 22:46:47 UTC (rev 18) @@ -3,13 +3,12 @@ #ifndef UNIVERSE_H #define UNIVERSE_H -#include "actions.h" -#include "animations.h" -#include "messages.h" - class Stars; class Planet; class Planets; +class Messages; +class ActionQueue; +class AnimationQueue; class Universe { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-04 22:01:03
|
Revision: 17 http://qonk.svn.sourceforge.net/qonk/?rev=17&view=rev Author: thebohemian Date: 2007-04-04 15:01:00 -0700 (Wed, 04 Apr 2007) Log Message: ----------- - added setters to Config class and simplified conversion methods - made Settings class completely static - changed every use of setting.FOO to Settings#FOO Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp branches/autoconf-2007-03-26-thebohemian/src/main.cpp branches/autoconf-2007-03-26-thebohemian/src/messages.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.cpp branches/autoconf-2007-03-26-thebohemian/src/players.cpp branches/autoconf-2007-03-26-thebohemian/src/readconf.cpp branches/autoconf-2007-03-26-thebohemian/src/readconf.h branches/autoconf-2007-03-26-thebohemian/src/settings.cpp branches/autoconf-2007-03-26-thebohemian/src/settings.h branches/autoconf-2007-03-26-thebohemian/src/universe.cpp Modified: branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp 2007-04-04 22:01:00 UTC (rev 17) @@ -1,13 +1,12 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <math.h> #include "coordinate.h" #include "settings.h" -#include <math.h> Coordinate::Coordinate() { - x = 0; - y = 0; + x = y = 0; } Coordinate::Coordinate( double x, double y ) { @@ -27,12 +26,12 @@ void Coordinate::setXMapped( int x ) { - this->x = ( (double)x - settings.getGameOffsetX() ) / settings.getGameWidth(); + this->x = ( (double)x - Settings::getGameOffsetX() ) / Settings::getGameWidth(); } void Coordinate::setYMapped( int y ) { - this->y = (double)y / settings.getGameHeight(); + this->y = (double)y / Settings::getGameHeight(); } double @@ -47,12 +46,12 @@ int Coordinate::getXMapped() const { - return settings.getGameOffsetX() + ( int )( settings.getGameWidth() * x ); + return Settings::getGameOffsetX() + ( int )( Settings::getGameWidth() * x ); } int Coordinate::getYMapped() const { - return ( int )( settings.getGameHeight() * y ); + return ( int )( Settings::getGameHeight() * y ); } double Modified: branches/autoconf-2007-03-26-thebohemian/src/main.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/main.cpp 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/main.cpp 2007-04-04 22:01:00 UTC (rev 17) @@ -30,8 +30,7 @@ States state; void render( SDL_Surface* screen, Universe* universe, Players* players ) { - - boxRGBA( screen, 0, 0, settings.getScreenWidth(), settings.getScreenHeight(), 0, 0, 0, 255 ); + boxRGBA( screen, 0, 0, Settings::getScreenWidth(), Settings::getScreenHeight(), 0, 0, 0, 255 ); universe->renderBackground( screen ); players->render( screen ); @@ -50,18 +49,20 @@ FPScounter = 0; } s << " (" << setiosflags(ios::fixed) << setprecision(2) << FPS << "FPS)"; - font->render( screen, 13, settings.getGameHeight() - 30, s.str().c_str(), 0x80, 0x80, 0x80 ); + font->render( screen, 13, Settings::getGameHeight() - 30, s.str().c_str(), 0x80, 0x80, 0x80 ); - SDL_UpdateRect(screen, 0, 0, settings.getScreenWidth(), settings.getScreenHeight() ); + SDL_UpdateRect(screen, 0, 0, Settings::getScreenWidth(), Settings::getScreenHeight() ); } void changeScreen(SDL_Surface **screen) { + long flags = SDL_SWSURFACE; + if (Settings::getFullscreen()) + { + flags |= SDL_FULLSCREEN; + } - if( settings.getFullscreen() ) - *screen = SDL_SetVideoMode( settings.getScreenWidth(), settings.getScreenHeight(), 32, SDL_SWSURFACE | SDL_FULLSCREEN ); - else - *screen = SDL_SetVideoMode( settings.getScreenWidth(), settings.getScreenHeight(), 32, SDL_SWSURFACE ); + *screen = SDL_SetVideoMode( Settings::getScreenWidth(), Settings::getScreenHeight(), 32, flags); } @@ -70,6 +71,8 @@ int numberOfPlanets; int numberOfComputerPlayers; + + Settings::init(); bool NextRound = true; while (NextRound){ @@ -83,8 +86,8 @@ numberOfComputerPlayers = atoi( argv[ 2 ] ); break; case 1: - numberOfPlanets = settings.getNumberOfPlanets(); - numberOfComputerPlayers = settings.getNumberOfComputerPlayers(); + numberOfPlanets = Settings::getNumberOfPlanets(); + numberOfComputerPlayers = Settings::getNumberOfComputerPlayers(); break; default: cerr << "Usage: " << argv[ 0 ] << " numberOfPlanets numberOfComputerPlayers" << endl; @@ -137,7 +140,6 @@ /* Initialize the display */ SDL_Surface *screen; -// cout << settings.getGameWidth() << "+" << settings.getGameOffsetX() << endl; changeScreen(&screen); @@ -221,13 +223,7 @@ nextComputerPlayers = numberOfComputerPlayers; } if(event.key.keysym.sym == SDLK_f){ - if(settings.getFullscreen()){ - settings.setFullscreen( false ); - } - else if(!settings.getFullscreen()){ - settings.setFullscreen( true ); - } - + Settings::setFullscreen(!Settings::getFullscreen()); changeScreen(&screen); } break; @@ -291,7 +287,7 @@ } cout << "Saving progress and settings." << endl; - settings.store(); + Settings::store(); delete font; delete universe; Modified: branches/autoconf-2007-03-26-thebohemian/src/messages.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/messages.cpp 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/messages.cpp 2007-04-04 22:01:00 UTC (rev 17) @@ -106,7 +106,7 @@ Messages::render( SDL_Surface* screen ) { cleanup(); int x = 12; - int y = settings.getGameHeight() - 28; + int y = Settings::getGameHeight() - 28; for( reverse_iterator i = rbegin(); i != rend(); i++ ) { i->second.render( screen, x, y, font, (int)timer.getTime() - (int)i->first ); } Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-04 22:01:00 UTC (rev 17) @@ -155,7 +155,11 @@ centerLocation.setY( 0.5 ); } if( owner != NULL ) - aaellipseRGBA( screen, centerLocation.getXMapped(), centerLocation.getYMapped(), (int)( rotationDistance * settings.getGameWidth() ), (int)( rotationDistance * settings.getGameHeight() ), getRed( owner->getColor() ), getGreen( owner->getColor() ), getBlue( owner->getColor() ), 64 ); + aaellipseRGBA( screen, centerLocation.getXMapped(), centerLocation.getYMapped(), + (int)( rotationDistance * Settings::getGameWidth() ), + (int)( rotationDistance * Settings::getGameHeight() ), + getRed( owner->getColor() ), getGreen( owner->getColor() ), + getBlue( owner->getColor() ), 64 ); if( getMoon() ) { mother->renderOrbit( screen ); } Modified: branches/autoconf-2007-03-26-thebohemian/src/players.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-04 22:01:00 UTC (rev 17) @@ -56,10 +56,10 @@ void Player::updateStats( double maximumPoints ) { - stats.push_back( (int)( getPoints() / maximumPoints * settings.getGameHeight() + 0.5 ) ); + stats.push_back( (int)( getPoints() / maximumPoints * Settings::getGameHeight() + 0.5 ) ); if( stats.size() == 1 ) { for( int i = 0; i < 127; i++ ) - stats.push_back( (int)( getPoints() / maximumPoints * settings.getGameHeight() + 0.5 ) ); + stats.push_back( (int)( getPoints() / maximumPoints * Settings::getGameHeight() + 0.5 ) ); } while( stats.size() > 128 ) { stats.erase( stats.begin() ); @@ -90,7 +90,12 @@ Player::renderStatsLog( SDL_Surface* screen ) { if( playerType == HUMAN ) for( unsigned int i = 1; i < stats.size(); i++ ) { - aalineRGBA( screen, settings.getScreenWidth() - stats.size() + i - 1, settings.getGameHeight() - stats[ i - 1 ], settings.getScreenWidth() - stats.size() + i, settings.getGameHeight() - stats[ i ], getRed( color ), getGreen( color ), getBlue( color ), i * 2 ); + aalineRGBA( screen, + Settings::getScreenWidth() - stats.size() + i - 1, + Settings::getGameHeight() - stats[ i - 1 ], + Settings::getScreenWidth() - stats.size() + i, + Settings::getGameHeight() - stats[ i ], + getRed( color ), getGreen( color ), getBlue( color ), i * 2 ); } } @@ -168,8 +173,8 @@ // Selects a single planet with middle mouse button if (mouseState & SDL_BUTTON(2)) { - double pointerX = ( (double)mouseX - settings.getGameOffsetX() ) / settings.getGameWidth(); - double pointerY = (double)mouseY / settings.getGameHeight(); + double pointerX = ( (double)mouseX - Settings::getGameOffsetX() ) / Settings::getGameWidth(); + double pointerY = (double)mouseY / Settings::getGameHeight(); Planet* closestPlanet = universe->planets->closestToCoordinate( Coordinate( pointerX, pointerY ), 1 ); if (closestPlanet && closestPlanet->getOwner() == this) { @@ -183,8 +188,8 @@ // Toggle a planet's state with middle mouse button /* if (mouseState & SDL_BUTTON(2)) { - double pointerX = ( (double)mouseX - settings.getGameOffsetX() ) / settings.getGameWidth(); - double pointerY = (double)mouseY / settings.getGameHeight(); + double pointerX = ( (double)mouseX - Settings::getGameOffsetX() ) / Settings::getGameWidth(); + double pointerY = (double)mouseY / Settings::getGameHeight(); Planet* closestPlanet = universe->planets->closestToCoordinate( Coordinate( pointerX, pointerY ), 1 ); if (closestPlanet) { @@ -196,8 +201,8 @@ if( mouseState & SDL_BUTTON( 3 ) ) { if( !rightMouseButtonPushed ) { rightMouseButtonPushed = true; - double pointerX = ( (double)mouseX - settings.getGameOffsetX() ) / settings.getGameWidth(); - double pointerY = (double)mouseY / settings.getGameHeight(); + double pointerX = ( (double)mouseX - Settings::getGameOffsetX() ) / Settings::getGameWidth(); + double pointerY = (double)mouseY / Settings::getGameHeight(); Planet* closestPlanet = universe->planets->closestToCoordinate( Coordinate( pointerX, pointerY ), 1 ); if( closestPlanet != NULL ) { Modified: branches/autoconf-2007-03-26-thebohemian/src/readconf.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/readconf.cpp 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/readconf.cpp 2007-04-04 22:01:00 UTC (rev 17) @@ -44,12 +44,13 @@ while (!file.eof()){ std::string line; getline( file, line ); + std::string::size_type loc = line.find( "=", 0 ); if( line[0] != '#' ) if( loc != std::string::npos ) { std::string parameter = stripWhiteSpace( line.substr( 0, loc ) ); std::string value = stripWhiteSpace( line.substr( loc + 1 ) ); - data[ parameter ] = value; + data[parameter] = value; } } file.close(); @@ -79,30 +80,69 @@ return defaultValue; } +void +Config::setValue( const std::string& parameter, std::string value) { + data[parameter] = value; +} + bool -Config::getValueBOOL( const std::string& parameter, bool defaultValue ) const { +Config::getValueAsBool( const std::string& parameter, bool defaultValue ) const { std::map< std::string, std::string >::const_iterator i = data.find( parameter ); if( i != data.end() ) - return str2bool(i->second); + return fromString<bool>(i->second); else return defaultValue; } +void +Config::setValue( const std::string& parameter, bool value) { + data[parameter] = toString<bool>(value); +} + int -Config::getValueINT( const std::string& parameter, int defaultValue ) const { +Config::getValueAsInt( const std::string& parameter, int defaultValue ) const { std::map< std::string, std::string >::const_iterator i = data.find( parameter ); if( i != data.end() ) - return str2int(i->second); + { + return fromString<int>(i->second); + } else return defaultValue; } +void +Config::setValue( const std::string& parameter, int value) { + data[parameter] = toString<int>(value); +} + void Config::print() const { for( std::map< std::string, std::string >::const_iterator i = data.begin(); i != data.end(); i++ ) std::cout << "'" << i->first << "' => '" << i->second << "'" << std::endl; } +template <typename T> +T +Config::fromString( const std::string& s) { + std::istringstream iss(s); + + T target; + + iss >> target; + + return target; +} + +template <typename T> +std::string +Config::toString( const T& t) { + std::ostringstream oss; + + oss << t; + + return oss.str(); +} + bool fileExists( const std::string& fileName ) { std::ifstream infile( fileName.c_str() ); @@ -122,14 +162,6 @@ } } -int -str2int( const std::string& s ) { - std::istringstream i(s); - int x; - i>>x; - return x; -} - std::string stripWhiteSpace( const std::string& original ) { int begin = original.find_first_not_of( " " ); Modified: branches/autoconf-2007-03-26-thebohemian/src/readconf.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/readconf.h 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/readconf.h 2007-04-04 22:01:00 UTC (rev 17) @@ -14,6 +14,7 @@ #include <sstream> class Config { + public: static Config& getInstance(); @@ -21,14 +22,23 @@ bool save(); std::string getValue( const std::string& parameter, std::string defaultValue = "") const; - bool getValueBOOL( const std::string& parameter, bool defaultValue = false ) const; - int getValueINT( const std::string& parameter, int defaultValue = 0 ) const; + void setValue (const std::string &, std::string value); + + bool getValueAsBool( const std::string& parameter, bool defaultValue = false ) const; + void setValue (const std::string &, bool value); + + int getValueAsInt( const std::string& parameter, int defaultValue = 0 ) const; + void setValue (const std::string &, int value); void print() const; private: Config( const std::string& fileName ); + template <typename T> static T fromString(const std::string&); + + template <typename T> static std::string toString(const T&); + std::map< std::string, std::string > data; std::string fileName; @@ -38,7 +48,6 @@ bool fileExists( const std::string& ); bool str2bool(const std::string& ); -int str2int(const std::string& ); std::string stripWhiteSpace( const std::string& ); #endif Modified: branches/autoconf-2007-03-26-thebohemian/src/settings.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/settings.cpp 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/settings.cpp 2007-04-04 22:01:00 UTC (rev 17) @@ -4,19 +4,36 @@ #include "settings.h" #include <iostream> -#include <fstream> -Settings::Settings() : config(Config::getInstance()) { +int Settings::screenWidth = 0; +int Settings::screenHeight = 0; +int Settings::gameWidth = 0; +int Settings::gameHeight = 0; +int Settings::gameOffsetX = 0; +bool Settings::fullscreen = false; +int Settings::numberOfPlanets = 0; +int Settings::numberOfComputerPlayers = 0; +Config& Settings::config = Config::getInstance(); + +void +Settings::init() { if (config.load()) std::cout << "configuration successfully loaded" << std::endl; else std::cout << "configuration was not available - using defaults" << std::endl; - setFullscreen(config.getValueBOOL("fullscreen", false)); - setResolution(config.getValueINT("width", 1024), - config.getValueINT("height", 768)); - setNumberOfPlanets( config.getValueINT("numberOfPlanets", 6)); - setNumberOfComputerPlayers( config.getValueINT("numberOfComputerPlayers", 1)); + setFullscreen(config.getValueAsBool("fullscreen", false)); + std::cout << "fullscreen: " << fullscreen << std::endl; + + setResolution(config.getValueAsInt("screenWidth", 1024), + config.getValueAsInt("screenHeight", 768)); + std::cout << "display size: " << screenWidth << "x" << screenHeight << std::endl; + + setNumberOfPlanets( config.getValueAsInt("numberOfPlanets", 6)); + std::cout << "number of planets: " << numberOfPlanets << std::endl; + + setNumberOfComputerPlayers( config.getValueAsInt("numberOfComputerPlayers", 1)); + std::cout << "number of computer players: " << numberOfComputerPlayers << std::endl; } void @@ -31,6 +48,12 @@ void Settings::store() { + config.setValue("screenWidth", screenWidth); + config.setValue("screenHeight", screenHeight); + config.setValue("fullscreen", fullscreen); + config.setValue("numberOfComputerPlayers", numberOfComputerPlayers); + config.setValue("numberOfPlanets", numberOfPlanets); + if (config.save()) std::cout << "Setting saved successfully." << std::endl; else Modified: branches/autoconf-2007-03-26-thebohemian/src/settings.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/settings.h 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/settings.h 2007-04-04 22:01:00 UTC (rev 17) @@ -11,35 +11,34 @@ class Settings { private: - int screenWidth, screenHeight, gameWidth, gameHeight, gameOffsetX; - bool fullscreen; + static int screenWidth, screenHeight, gameWidth, gameHeight, gameOffsetX; + static bool fullscreen; - int numberOfPlanets; - int numberOfComputerPlayers; + static int numberOfPlanets; + static int numberOfComputerPlayers; - Config& config; + static Config& config; public: - Settings(); - void setFullscreen( bool b ) { fullscreen = b; } - bool getFullscreen() { return fullscreen; } + static void init(); - void setResolution(int, int); - int getScreenWidth() { return screenWidth; } - int getScreenHeight() { return screenHeight; } - int getGameWidth() { return gameWidth; } - int getGameHeight() { return gameHeight; } - int getGameOffsetX() { return gameOffsetX; } + static void setFullscreen( bool b ) { fullscreen = b; } + static bool getFullscreen() { return fullscreen; } - int getNumberOfPlanets() { return numberOfPlanets; } - int setNumberOfPlanets(int p) { numberOfPlanets = p; } + static void setResolution(int, int); + static int getScreenWidth() { return screenWidth; } + static int getScreenHeight() { return screenHeight; } + static int getGameWidth() { return gameWidth; } + static int getGameHeight() { return gameHeight; } + static int getGameOffsetX() { return gameOffsetX; } - int getNumberOfComputerPlayers() { return numberOfComputerPlayers; } - int setNumberOfComputerPlayers(int p) { numberOfComputerPlayers = p; } + static int getNumberOfPlanets() { return numberOfPlanets; } + static int setNumberOfPlanets(int p) { numberOfPlanets = p; } - void store(); + static int getNumberOfComputerPlayers() { return numberOfComputerPlayers; } + static int setNumberOfComputerPlayers(int p) { numberOfComputerPlayers = p; } + + static void store(); }; -static Settings settings; - #endif Modified: branches/autoconf-2007-03-26-thebohemian/src/universe.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-03 19:52:33 UTC (rev 16) +++ branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-04 22:01:00 UTC (rev 17) @@ -54,16 +54,25 @@ Uint32 radarColor = 0xfee190; double s = 1.0 / radarSteps; for( int i = 1; i <= radarSteps; i++ ) { - aaellipseRGBA( screen, settings.getGameOffsetX() + settings.getGameWidth() / 2, settings.getGameHeight() / 2, (int)( i * s * settings.getGameWidth() / 2 ), (int)( i * s * settings.getGameHeight() / 2 ), 144, 225, 144, 64 ); + aaellipseRGBA( screen, Settings::getGameOffsetX() + Settings::getGameWidth() / 2, + Settings::getGameHeight() / 2, (int) (i * s * Settings::getGameWidth() / 2), + (int)( i * s * Settings::getGameHeight() / 2 ), 144, 225, 144, 64 ); } - lineRGBA( screen, settings.getGameOffsetX() + settings.getGameWidth() / 2, 0, settings.getGameOffsetX() + settings.getGameWidth() / 2, settings.getGameHeight(), 255, 225, 144, 64 ); - lineRGBA( screen, settings.getGameOffsetX(), settings.getGameHeight() / 2, settings.getGameOffsetX() + settings.getGameWidth(), settings.getGameHeight() / 2, 255, 225, 144, 64 ); + lineRGBA( screen, + Settings::getGameOffsetX() + Settings::getGameWidth() / 2, 0, + Settings::getGameOffsetX() + Settings::getGameWidth() / 2, + Settings::getGameHeight(), 255, 225, 144, 64 ); + lineRGBA( screen, + Settings::getGameOffsetX(), + Settings::getGameHeight() / 2, + Settings::getGameOffsetX() + Settings::getGameWidth(), + Settings::getGameHeight() / 2, 255, 225, 144, 64 ); int mouseX; int mouseY; Uint8 mouseState = SDL_GetMouseState( &mouseX, &mouseY ); - double pointerX = ( (double)mouseX - settings.getGameOffsetX() ) / settings.getGameWidth(); - double pointerY = (double)mouseY / settings.getGameHeight(); + double pointerX = ( (double)mouseX - Settings::getGameOffsetX() ) / Settings::getGameWidth(); + double pointerY = (double)mouseY / Settings::getGameHeight(); Planet* closestPlanet = planets->closestToCoordinate( Coordinate( pointerX, pointerY ), 1 ); if( !( mouseState & SDL_BUTTON(1) ) ) { @@ -80,8 +89,8 @@ // Sun in the middle - Sint16 x0 = settings.getGameOffsetX() + settings.getGameWidth() / 2; - Sint16 y0 = settings.getGameHeight() / 2; + Sint16 x0 = Settings::getGameOffsetX() + Settings::getGameWidth() / 2; + Sint16 y0 = Settings::getGameHeight() / 2; filledTrigonRGBA( screen, x0+5, y0, x0-5,y0, x0, y0+15, 255, 205, 0, 255); filledTrigonRGBA( screen, x0+5, y0, x0-5,y0, x0, y0-15, 255, 205, 0, 255); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-03 19:52:35
|
Revision: 16 http://qonk.svn.sourceforge.net/qonk/?rev=16&view=rev Author: thebohemian Date: 2007-04-03 12:52:33 -0700 (Tue, 03 Apr 2007) Log Message: ----------- - removed setting pkgdatadir variable Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/data/Makefile.am Modified: branches/autoconf-2007-03-26-thebohemian/data/Makefile.am =================================================================== --- branches/autoconf-2007-03-26-thebohemian/data/Makefile.am 2007-04-03 19:51:27 UTC (rev 15) +++ branches/autoconf-2007-03-26-thebohemian/data/Makefile.am 2007-04-03 19:52:33 UTC (rev 16) @@ -1,5 +1,3 @@ -pkgdatadir = $(datadir)/games/@PACKAGE@/data/ - pkgdata_DATA = font.ttf EXTRA_DIST = $(pkgdata_DATA) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-03 19:51:28
|
Revision: 15 http://qonk.svn.sourceforge.net/qonk/?rev=15&view=rev Author: thebohemian Date: 2007-04-03 12:51:27 -0700 (Tue, 03 Apr 2007) Log Message: ----------- - fixed argument ordering in setting.cpp - declare location of package data in compiler flags Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/src/Makefile.am branches/autoconf-2007-03-26-thebohemian/src/settings.cpp Modified: branches/autoconf-2007-03-26-thebohemian/src/Makefile.am =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/Makefile.am 2007-04-01 18:42:18 UTC (rev 14) +++ branches/autoconf-2007-03-26-thebohemian/src/Makefile.am 2007-04-03 19:51:27 UTC (rev 15) @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -DPKG_DATA_DIR="\"$(pkgdatadir)\"" +AM_CPPFLAGS=-DPKG_DATA_DIR="\"$(pkgdatadir)/\"" bin_PROGRAMS = qonk Modified: branches/autoconf-2007-03-26-thebohemian/src/settings.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/settings.cpp 2007-04-01 18:42:18 UTC (rev 14) +++ branches/autoconf-2007-03-26-thebohemian/src/settings.cpp 2007-04-03 19:51:27 UTC (rev 15) @@ -13,8 +13,8 @@ std::cout << "configuration was not available - using defaults" << std::endl; setFullscreen(config.getValueBOOL("fullscreen", false)); - setResolution(config.getValueINT("height", 768), - config.getValueINT("width", 1024)); + setResolution(config.getValueINT("width", 1024), + config.getValueINT("height", 768)); setNumberOfPlanets( config.getValueINT("numberOfPlanets", 6)); setNumberOfComputerPlayers( config.getValueINT("numberOfComputerPlayers", 1)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-01 18:42:24
|
Revision: 14 http://qonk.svn.sourceforge.net/qonk/?rev=14&view=rev Author: thebohemian Date: 2007-04-01 11:42:18 -0700 (Sun, 01 Apr 2007) Log Message: ----------- - Initial half-working version with autoconf support. Modified Paths: -------------- branches/autoconf-2007-03-26-thebohemian/src/actions.cpp branches/autoconf-2007-03-26-thebohemian/src/animations.cpp branches/autoconf-2007-03-26-thebohemian/src/animations.h branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp branches/autoconf-2007-03-26-thebohemian/src/extensions.h branches/autoconf-2007-03-26-thebohemian/src/main.cpp branches/autoconf-2007-03-26-thebohemian/src/messages.cpp branches/autoconf-2007-03-26-thebohemian/src/messages.h branches/autoconf-2007-03-26-thebohemian/src/planets.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.h branches/autoconf-2007-03-26-thebohemian/src/players.cpp branches/autoconf-2007-03-26-thebohemian/src/players.h branches/autoconf-2007-03-26-thebohemian/src/selection.cpp branches/autoconf-2007-03-26-thebohemian/src/selection.h branches/autoconf-2007-03-26-thebohemian/src/ships.cpp branches/autoconf-2007-03-26-thebohemian/src/ships.h branches/autoconf-2007-03-26-thebohemian/src/stars.cpp branches/autoconf-2007-03-26-thebohemian/src/stars.h branches/autoconf-2007-03-26-thebohemian/src/timer.h branches/autoconf-2007-03-26-thebohemian/src/universe.cpp branches/autoconf-2007-03-26-thebohemian/src/universe.h Added Paths: ----------- branches/autoconf-2007-03-26-thebohemian/Makefile.am branches/autoconf-2007-03-26-thebohemian/autogen.sh branches/autoconf-2007-03-26-thebohemian/config.h.in branches/autoconf-2007-03-26-thebohemian/configure.ac branches/autoconf-2007-03-26-thebohemian/data/Makefile.am branches/autoconf-2007-03-26-thebohemian/src/Makefile.am branches/autoconf-2007-03-26-thebohemian/src/readconf.cpp branches/autoconf-2007-03-26-thebohemian/src/readconf.h branches/autoconf-2007-03-26-thebohemian/src/settings.cpp branches/autoconf-2007-03-26-thebohemian/src/settings.h Removed Paths: ------------- branches/autoconf-2007-03-26-thebohemian/src/ReadConf.cpp branches/autoconf-2007-03-26-thebohemian/src/ReadConf.h branches/autoconf-2007-03-26-thebohemian/src/config.cpp branches/autoconf-2007-03-26-thebohemian/src/config.h Added: branches/autoconf-2007-03-26-thebohemian/Makefile.am =================================================================== --- branches/autoconf-2007-03-26-thebohemian/Makefile.am (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/Makefile.am 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,4 @@ +SUBDIRS = src data + +EXTRA_DIST = README COPYING missing Makefile.manual TODO + Added: branches/autoconf-2007-03-26-thebohemian/autogen.sh =================================================================== --- branches/autoconf-2007-03-26-thebohemian/autogen.sh (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/autogen.sh 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,3 @@ +#!/bin/sh + +aclocal && automake --foreign && autoheader && autoconf Property changes on: branches/autoconf-2007-03-26-thebohemian/autogen.sh ___________________________________________________________________ Name: svn:executable + * Added: branches/autoconf-2007-03-26-thebohemian/config.h.in =================================================================== --- branches/autoconf-2007-03-26-thebohemian/config.h.in (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/config.h.in 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,106 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `SDL' library (-lSDL). */ +#undef HAVE_LIBSDL + +/* Define to 1 if you have the `SDL_gfx' library (-lSDL_gfx). */ +#undef HAVE_LIBSDL_GFX + +/* Define to 1 if you have the `SDL_ttf' library (-lSDL_ttf). */ +#undef HAVE_LIBSDL_TTF + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mkdir' function. */ +#undef HAVE_MKDIR + +/* Define to 1 if you have the <SDL/SDL_gfxPrimitives.h> header file. */ +#undef HAVE_SDL_SDL_GFXPRIMITIVES_H + +/* Define to 1 if you have the <SDL/SDL.h> header file. */ +#undef HAVE_SDL_SDL_H + +/* Define to 1 if you have the <SDL/SDL_ttf.h> header file. */ +#undef HAVE_SDL_SDL_TTF_H + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `sqrt' function. */ +#undef HAVE_SQRT + +/* Define to 1 if stdbool.h conforms to C99. */ +#undef HAVE_STDBOOL_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/select.h> header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the <sys/socket.h> header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to the type of arg 1 for `select'. */ +#undef SELECT_TYPE_ARG1 + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#undef SELECT_TYPE_ARG234 + +/* Define to the type of arg 5 for `select'. */ +#undef SELECT_TYPE_ARG5 + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const Added: branches/autoconf-2007-03-26-thebohemian/configure.ac =================================================================== --- branches/autoconf-2007-03-26-thebohemian/configure.ac (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/configure.ac 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,42 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT([qonk], [0.0.3], [qon...@li...]) +AC_CANONICAL_TARGET +AM_INIT_AUTOMAKE + +AC_CONFIG_SRCDIR([src/animations.h]) +AC_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC + +AC_LANG_C + +AM_PATH_SDL([1.2.0], [:], + AC_MSG_ERROR([No proper SDL found. Please install at least version 1.2.0!])) + + +# Checks for libraries. +AC_CHECK_LIB([SDL], [SDL_Init]) +AC_CHECK_LIB([SDL_ttf], [TTF_Init]) +AC_CHECK_LIB([SDL_gfx], [pixelColor]) + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([stdlib.h SDL/SDL.h SDL/SDL_gfxPrimitives.h SDL/SDL_ttf.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_CONST + +# Checks for library functions. +AC_FUNC_SELECT_ARGTYPES +AC_CHECK_FUNCS([atexit mkdir select sqrt]) + +AC_CONFIG_FILES([Makefile + data/Makefile + src/Makefile]) +AC_OUTPUT Added: branches/autoconf-2007-03-26-thebohemian/data/Makefile.am =================================================================== --- branches/autoconf-2007-03-26-thebohemian/data/Makefile.am (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/data/Makefile.am 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,5 @@ +pkgdatadir = $(datadir)/games/@PACKAGE@/data/ + +pkgdata_DATA = font.ttf + +EXTRA_DIST = $(pkgdata_DATA) Added: branches/autoconf-2007-03-26-thebohemian/src/Makefile.am =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/Makefile.am (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/src/Makefile.am 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,36 @@ +AM_CPPFLAGS = -DPKG_DATA_DIR="\"$(pkgdatadir)\"" + +bin_PROGRAMS = qonk + +qonk_SOURCES = " \ + actions.cpp \ + actions.h \ + animations.cpp \ + animations.h \ + coordinate.cpp \ + coordinate.h \ + extensions.cpp \ + extensions.h \ + fonts.cpp \ + fonts.h \ + main.cpp \ + messages.cpp \ + messages.h \ + planets.cpp \ + planets.h \ + players.cpp \ + players.h \ + readconf.cpp \ + readconf.h \ + selection.cpp \ + selection.h \ + settings.cpp \ + settings.h \ + ships.cpp \ + ships.h \ + stars.cpp \ + stars.h \ + timer.cpp \ + timer.h \ + universe.cpp \ + universe.h " Deleted: branches/autoconf-2007-03-26-thebohemian/src/ReadConf.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ReadConf.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/ReadConf.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,91 +0,0 @@ -#include "ReadConf.h" - -Config::Config( const std::string& configFileName ){ - std::ifstream file( configFileName.c_str() ); - while (!file.eof()){ - std::string line; - getline( file, line ); - std::string::size_type loc = line.find( "=", 0 ); - if( line[0] != '#' ) - if( loc != std::string::npos ) { - std::string parameter = stripWhiteSpace( line.substr( 0, loc ) ); - std::string value = stripWhiteSpace( line.substr( loc + 1 ) ); - data[ parameter ] = value; - } - } - file.close(); - std::cout << "config file read" << std::endl; -} - -std::string -Config::getValue( const std::string& parameter ) const { - std::map< std::string, std::string >::const_iterator i = data.find( parameter ); - if( i != data.end() ) - return i->second; - else - return ""; -} - -bool -Config::getValueBOOL( const std::string& parameter ) const { - std::string s = getValue(parameter); - return str2bool(s); -} - -int -Config::getValueINT( const std::string& parameter ) const { - std::string s = getValue(parameter); - return str2int(s); -} - -void -Config::print() const { - for( std::map< std::string, std::string >::const_iterator i = data.begin(); i != data.end(); i++ ) - std::cout << "'" << i->first << "' => '" << i->second << "'" << std::endl; -} - -bool -fileExists( const std::string& fileName ) { - std::ifstream infile( fileName.c_str() ); - bool result = infile.good(); - infile.close(); - return result; -} - -void -createFile( const std::string& fileName, std::vector< std::string > content ){ - if( !fileExists( fileName ) ){ - std::ofstream outfile( fileName.c_str() ); - for( std::vector< std::string >::const_iterator iter = content.begin(); iter != content.end(); iter++ ) { - outfile.write( (*iter).data(), (*iter).size() ); - outfile.write( "\n", 1 ); - } - outfile.close(); - } -} - -bool -str2bool( const std::string& s ) { - if (s == std::string("true")) { - return true; - } else if (s == std::string("false")){ - return false; - } else { - std::cerr << "Invalid bool type"; - } -} - -int -str2int( const std::string& s ) { - std::istringstream i(s); - int x; - i>>x; - return x; -} - -std::string -stripWhiteSpace( const std::string& original ) { - int begin = original.find_first_not_of( " " ); - int end = original.find_last_not_of( " " ); - return original.substr( begin, end - begin + 1 ); -} Deleted: branches/autoconf-2007-03-26-thebohemian/src/ReadConf.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ReadConf.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/ReadConf.h 2007-04-01 18:42:18 UTC (rev 14) @@ -1,36 +0,0 @@ -// ReadConf.h -// Class for reading named values from configuration files -// Troels Kofoed Jacobsen, Mar 19 2007, tkj...@gm... -// Licensed under GPLv2 -#ifndef READCONF_H -#define READCONF_H - -#include <string> -#include <map> -#include <vector> -#include <fstream> -#include <iostream> -#include <cctype> -#include <sstream> - -class Config { -public: - Config( const std::string& fileName ); - - std::string getValue( const std::string& parameter ) const; - bool getValueBOOL( const std::string& parameter ) const; - int getValueINT( const std::string& parameter ) const; - - void print() const; - -private: - std::map< std::string, std::string > data; -}; - -bool fileExists( const std::string& ); -void createFile( const std::string&, std::vector< std::string > ); -bool str2bool(const std::string& ); -int str2int(const std::string& ); -std::string stripWhiteSpace( const std::string& ); - -#endif Modified: branches/autoconf-2007-03-26-thebohemian/src/actions.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/actions.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/actions.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -2,7 +2,7 @@ #include "actions.h" -#include "config.h" +#include "settings.h" #include <iostream> // ##### ACTION ##### Modified: branches/autoconf-2007-03-26-thebohemian/src/animations.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/animations.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/animations.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,9 +1,11 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <SDL/SDL_gfxPrimitives.h> + #include "animations.h" -#include <SDL_gfxPrimitives.h> +#include "timer.h" +#include "planets.h" -#include <iostream> void AnimationQueue::render( SDL_Surface* screen ) { @@ -33,8 +35,8 @@ Uint32 currentTime = timer.getTime(); if( ( currentTime > startTime ) && ( currentTime < endTime ) ) { double percentage = (double)( currentTime - startTime ) / ( endTime - startTime ); - filledCircleRGBA( screen, planet->getLocation().getXMapped(), planet->getLocation().getYMapped(), (int)( size * sin( percentage * PI ) ), r, g, b, (int)( ( 255 - 255 * percentage ) * 0.05 ) ); + filledCircleRGBA( screen, planet->getLocation().getXMapped(), planet->getLocation().getYMapped(), (int)( size * sin( percentage * M_PI ) ), r, g, b, (int)( ( 255 - 255 * percentage ) * 0.05 ) ); if( circle ) - aacircleRGBA( screen, planet->getLocation().getXMapped(), planet->getLocation().getYMapped(), (int)( size * sin( percentage * PI ) ), r, g, b, 255 - (int)( 255 * percentage ) ); + aacircleRGBA( screen, planet->getLocation().getXMapped(), planet->getLocation().getYMapped(), (int)( size * sin( percentage * M_PI ) ), r, g, b, 255 - (int)( 255 * percentage ) ); } } Modified: branches/autoconf-2007-03-26-thebohemian/src/animations.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/animations.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/animations.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,13 +3,10 @@ #ifndef ANIMATIONS_H #define ANIMATIONS_H +#include <SDL/SDL.h> + #include "actions.h" -#include "coordinate.h" -#include "config.h" -#include "planets.h" -#include <math.h> - class Planet; class Animation : public Action { Deleted: branches/autoconf-2007-03-26-thebohemian/src/config.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/config.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/config.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,76 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "config.h" -#include <iostream> - -class Config; - -Settings::Settings() { - //setResolution( 800, 600 ); - //setFullscreen( true ); - - //Create configuration file if it does not exist - if (!fileExists("qonk.conf")){ - vector<string> v; - v.push_back("# Qonk configuration file "); - v.push_back("# Format: entry = value (The spaces is optional)\n"); - v.push_back("# Window"); - v.push_back("fullscreen = true"); - v.push_back("width = 1024"); - v.push_back("height = 768\n"); - v.push_back("# Settings for first round"); - v.push_back("numberOfPlanets = 6"); - v.push_back("numberOfComputerPlayers = 1"); - createFile("qonk.conf",v); - } - Config config("qonk.conf"); - //Read settings form qonk.conf - bool fs = config.getValueBOOL("fullscreen"); - int h = config.getValueINT("height"); - int w = config.getValueINT("width"); - setResolution(w, h ); - setFullscreen( fs ); -} - -Settings::Settings(int w, int h, bool fs) { - setResolution( w, h ); - setFullscreen( fs ); -} - -void -Settings::setResolution( int width, int height ) { - screenWidth = width; - screenHeight = height; - gameWidth = height; - gameHeight = height; - gameOffsetX = ( width - height ) / 2; -} - -void -Settings::setFullscreen( bool b ) { - fullscreen = b; -} - -int Settings::getScreenWidth() { - return screenWidth; -} - -int Settings::getScreenHeight() { - return screenHeight; -} - -int Settings::getGameWidth() { - return gameWidth; -} - -int Settings::getGameHeight() { - return gameHeight; -} - -int Settings::getGameOffsetX() { - return gameOffsetX; -} - -bool Settings::getFullscreen() { - return fullscreen; -} Deleted: branches/autoconf-2007-03-26-thebohemian/src/config.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/config.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/config.h 2007-04-01 18:42:18 UTC (rev 14) @@ -1,35 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef CONFIG_H -#define CONFIG_H - -#define PI 3.14159265 - -#include "timer.h" -#include "ReadConf.h" -#include <vector> -#include <string> - -static Timer timer; - -class Settings { -private: - int screenWidth, screenHeight, gameWidth, gameHeight, gameOffsetX; - bool fullscreen; -public: - Settings(); - Settings(int, int, bool); - void setResolution( int width, int height ); - void setFullscreen( bool b ); - int getScreenWidth(); - int getScreenHeight(); - int getGameWidth(); - int getGameHeight(); - int getGameOffsetX(); - bool getFullscreen(); -}; - -static Settings settings; -//static Config config("qonk.conf"); - -#endif Modified: branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -2,7 +2,7 @@ #include "coordinate.h" -#include "config.h" +#include "settings.h" #include <math.h> Coordinate::Coordinate() { Modified: branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,7 +1,7 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <SDL/SDL_gfxPrimitives.h> #include "extensions.h" -#include <SDL_gfxPrimitives.h> void alphaBlend( SDL_Surface* surface, Uint8 alpha ) { Modified: branches/autoconf-2007-03-26-thebohemian/src/extensions.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/extensions.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/extensions.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,10 +3,7 @@ #ifndef EXTENSIONS_H #define EXTENSIONS_H -#include "config.h" #include <SDL/SDL.h> -#include <sstream> -using namespace std; void alphaBlend( SDL_Surface* surface, Uint8 alpha ); Modified: branches/autoconf-2007-03-26-thebohemian/src/main.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/main.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/main.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,4 +1,7 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <SDL/SDL_gfxPrimitives.h> +#include <SDL/SDL.h> +#include <SDL/SDL_ttf.h> #include "coordinate.h" #include "stars.h" @@ -7,12 +10,9 @@ #include "players.h" #include "universe.h" #include "fonts.h" -#include "ReadConf.h" -#include "config.h" +#include "settings.h" +#include "extensions.h" -#include <SDL_gfxPrimitives.h> -#include <SDL/SDL.h> -#include <SDL/SDL_ttf.h> #include <math.h> #include <iostream> @@ -66,14 +66,6 @@ int main(int argc, char** argv) { - -/* bool fullscreen = config.getValueBOOL("fullscreen"); - int h = config.getValueINT("height"); - int w = config.getValueINT("width"); - - settings.setResolution( w, h ); - settings.setFullscreen( fullscreen ); -*/ bool FirstRun = true; int numberOfPlanets; @@ -85,17 +77,21 @@ if (FirstRun){ FirstRun=false; - if( argc != 3 ) { - //cerr << "Usage: " << argv[ 0 ] << " numberOfPlanets numberOfComputerPlayers" << endl; - //cerr << "Setting to default 6 planets and 1 computer player" << endl; -// numberOfPlanets = config.getValueINT("numberOfPlanets"); -// numberOfComputerPlayers = config.getValueINT("numberOfComputerPlayers"); - numberOfPlanets = 6; - numberOfComputerPlayers = 1; - } else { - numberOfPlanets = atoi( argv[ 1 ] ); - numberOfComputerPlayers = atoi( argv[ 2 ] ); + switch (argc) { + case 3: + numberOfPlanets = atoi( argv[ 1 ] ); + numberOfComputerPlayers = atoi( argv[ 2 ] ); + break; + case 1: + numberOfPlanets = settings.getNumberOfPlanets(); + numberOfComputerPlayers = settings.getNumberOfComputerPlayers(); + break; + default: + cerr << "Usage: " << argv[ 0 ] << " numberOfPlanets numberOfComputerPlayers" << endl; + exit(1); + break; } + if( numberOfPlanets <= 1 ) { cerr << "Resetting to least of 2 planets" << endl; numberOfPlanets = 2; @@ -132,7 +128,7 @@ exit( 1 ); } atexit( TTF_Quit ); - font = new Font( "font.ttf", 18 ); + font = new Font( PKG_DATA_DIR "font.ttf", 18 ); srand( time( NULL) ); @@ -293,6 +289,9 @@ // SDL_Delay( 20 ); } + + cout << "Saving progress and settings." << endl; + settings.store(); delete font; delete universe; Modified: branches/autoconf-2007-03-26-thebohemian/src/messages.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/messages.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/messages.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,6 +1,11 @@ // Copyright 2005 by Anthony Liekens an...@li... #include "messages.h" +#include "timer.h" +#include "settings.h" +#include "coordinate.h" +#include "extensions.h" +#include "universe.h" Message::Message( string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ) { @@ -79,7 +84,7 @@ } Messages::Messages() { - font = new Font( "font.ttf", 12 ); + font = new Font( PKG_DATA_DIR "font.ttf", 12 ); } Messages::~Messages() { Modified: branches/autoconf-2007-03-26-thebohemian/src/messages.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/messages.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/messages.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,15 +3,12 @@ #ifndef MESSAGES_H #define MESSAGES_H -#include "fonts.h" -#include "extensions.h" -#include "config.h" -#include "universe.h" -#include <SDL/SDL.h> #include <map> -#include <string> -using namespace std; +#include <SDL/SDL.h> + +#include "fonts.h" + class Universe; class Message { Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,12 +1,14 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <SDL/SDL_gfxPrimitives.h> + #include "planets.h" +#include "timer.h" +#include "ships.h" +#include "extensions.h" +#include "settings.h" -#include <SDL_gfxPrimitives.h> -#include <iostream> -#include <math.h> - // ##### PLANET ##### Planet::Planet() { @@ -197,8 +199,8 @@ int counter = 0; double offset = 500 * rotationDistance + (double)timer.getTime() / 10000; for( list< Ship* >::iterator i = residentShips.begin(); i != residentShips.end(); i++ ) { - double shipX = location.getX() + 0.02 * cos( offset + counter * 2 * PI / residentShips.size() ); - double shipY = location.getY() + 0.02 * sin( offset + counter * 2 * PI / residentShips.size() ); + double shipX = location.getX() + 0.02 * cos( offset + counter * 2 * M_PI / residentShips.size() ); + double shipY = location.getY() + 0.02 * sin( offset + counter * 2 * M_PI / residentShips.size() ); (*i)->setLocation( shipX, shipY ); counter++; } Modified: branches/autoconf-2007-03-26-thebohemian/src/planets.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/planets.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/planets.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,22 +3,18 @@ #ifndef PLANETS_H #define PLANETS_H +#include <list> + +#include <SDL/SDL.h> + #include "coordinate.h" -#include "ships.h" -#include "extensions.h" -#include "selection.h" +#include "players.h" #include "actions.h" -#include "config.h" -#include <SDL/SDL.h> -#include <sstream> -#include <list> +#include "universe.h" + using namespace std; class Ship; -class Ships; -class Player; -class Players; -class Universe; class Planet { private: Modified: branches/autoconf-2007-03-26-thebohemian/src/players.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/players.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,11 +1,16 @@ // Copyright 2005 by Anthony Liekens an...@li... -#include "players.h" +#include <map> -#include <SDL_gfxPrimitives.h> +#include <SDL/SDL_gfxPrimitives.h> -#include <iostream> -#include <map> +#include "players.h" +#include "planets.h" +#include "universe.h" +#include "ships.h" +#include "extensions.h" +#include "timer.h" +#include "settings.h" // ##### PLAYER ##### Modified: branches/autoconf-2007-03-26-thebohemian/src/players.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/players.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/players.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,20 +3,17 @@ #ifndef PLAYERS_H #define PLAYERS_H -#include "ships.h" -#include "planets.h" -#include "universe.h" -#include "actions.h" -#include "messages.h" +#include <vector> #include <list> using namespace std; -class Ship; +#include "actions.h" +#include "messages.h" +#include "selection.h" + class Ships; -class Planet; -class Planets; -class Selection; class Universe; +class Planet; class Player { public: Copied: branches/autoconf-2007-03-26-thebohemian/src/readconf.cpp (from rev 13, branches/autoconf-2007-03-26-thebohemian/src/ReadConf.cpp) =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/readconf.cpp (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/src/readconf.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,138 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <sys/stat.h> + +#include "readconf.h" + +Config *Config::instance = 0; + +Config& +Config::getInstance() { + if (!instance) { + instance = new Config("qonk.settings"); + } + + return *instance; +} + +Config::Config( const std::string& configFileName ){ + std::string pathname = ""; +#ifdef WINDOWS + // Do nothing. Falls back to application directory. +#elif MAC_OSX + // Get from some mysterious directory ... +#else + // GNU/LINUX/BSD/POSIX/... + if(getenv("HOME")!=NULL) { + pathname = getenv("HOME"); + pathname += "/.qonk/"; + mkdir(pathname.c_str(), 0755); + } +#endif + + fileName = pathname + configFileName; +} + +bool +Config::load() { + if( !fileExists(fileName)) + return false; + + std::ifstream file( fileName.c_str() ); + while (!file.eof()){ + std::string line; + getline( file, line ); + std::string::size_type loc = line.find( "=", 0 ); + if( line[0] != '#' ) + if( loc != std::string::npos ) { + std::string parameter = stripWhiteSpace( line.substr( 0, loc ) ); + std::string value = stripWhiteSpace( line.substr( loc + 1 ) ); + data[ parameter ] = value; + } + } + file.close(); + + return true; +} + +bool +Config::save() { + std::ofstream outfile( fileName.c_str() ); + for( std::map< std::string, std::string >::const_iterator i = data.begin(); i != data.end(); i++ ) { + std::string temp = i->first + "=" + i->second; + outfile.write( temp.data(), temp.size() ); + outfile.write( "\n", 1 ); + } + outfile.close(); + + return true; +} + +std::string +Config::getValue( const std::string& parameter, std::string defaultValue ) const { + std::map< std::string, std::string >::const_iterator i = data.find( parameter ); + if( i != data.end() ) + return i->second; + else + return defaultValue; +} + +bool +Config::getValueBOOL( const std::string& parameter, bool defaultValue ) const { + std::map< std::string, std::string >::const_iterator i = data.find( parameter ); + if( i != data.end() ) + return str2bool(i->second); + else + return defaultValue; +} + +int +Config::getValueINT( const std::string& parameter, int defaultValue ) const { + std::map< std::string, std::string >::const_iterator i = data.find( parameter ); + if( i != data.end() ) + return str2int(i->second); + else + return defaultValue; +} + +void +Config::print() const { + for( std::map< std::string, std::string >::const_iterator i = data.begin(); i != data.end(); i++ ) + std::cout << "'" << i->first << "' => '" << i->second << "'" << std::endl; +} + +bool +fileExists( const std::string& fileName ) { + std::ifstream infile( fileName.c_str() ); + bool result = infile.good(); + infile.close(); + return result; +} + +bool +str2bool( const std::string& s ) { + if (s == std::string("true")) { + return true; + } else if (s == std::string("false")){ + return false; + } else { + std::cerr << "Invalid bool type"; + } +} + +int +str2int( const std::string& s ) { + std::istringstream i(s); + int x; + i>>x; + return x; +} + +std::string +stripWhiteSpace( const std::string& original ) { + int begin = original.find_first_not_of( " " ); + int end = original.find_last_not_of( " " ); + return original.substr( begin, end - begin + 1 ); +} Copied: branches/autoconf-2007-03-26-thebohemian/src/readconf.h (from rev 13, branches/autoconf-2007-03-26-thebohemian/src/ReadConf.h) =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/readconf.h (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/src/readconf.h 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,44 @@ +// ReadConf.h +// Class for reading named values from configuration files +// Troels Kofoed Jacobsen, Mar 19 2007, tkj...@gm... +// Licensed under GPLv2 +#ifndef READCONF_H +#define READCONF_H + +#include <string> +#include <map> +#include <vector> +#include <fstream> +#include <iostream> +#include <cctype> +#include <sstream> + +class Config { +public: + static Config& getInstance(); + + bool load(); + bool save(); + + std::string getValue( const std::string& parameter, std::string defaultValue = "") const; + bool getValueBOOL( const std::string& parameter, bool defaultValue = false ) const; + int getValueINT( const std::string& parameter, int defaultValue = 0 ) const; + + void print() const; + +private: + Config( const std::string& fileName ); + + std::map< std::string, std::string > data; + + std::string fileName; + + static Config *instance; +}; + +bool fileExists( const std::string& ); +bool str2bool(const std::string& ); +int str2int(const std::string& ); +std::string stripWhiteSpace( const std::string& ); + +#endif Modified: branches/autoconf-2007-03-26-thebohemian/src/selection.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/selection.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/selection.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,8 +1,9 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <iostream> +#include <SDL/SDL_gfxPrimitives.h> + #include "selection.h" -#include <SDL_gfxPrimitives.h> -#include <iostream> Selection::Selection() { state = NOT_SELECTING; Modified: branches/autoconf-2007-03-26-thebohemian/src/selection.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/selection.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/selection.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,7 +3,6 @@ #ifndef SELECTION_H #define SELECTION_H -#include "config.h" #include "coordinate.h" #include <SDL/SDL.h> Copied: branches/autoconf-2007-03-26-thebohemian/src/settings.cpp (from rev 13, branches/autoconf-2007-03-26-thebohemian/src/config.cpp) =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/settings.cpp (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/src/settings.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,38 @@ +// Copyright 2005 by Anthony Liekens an...@li... + +#include "readconf.h" +#include "settings.h" + +#include <iostream> +#include <fstream> + +Settings::Settings() : config(Config::getInstance()) { + if (config.load()) + std::cout << "configuration successfully loaded" << std::endl; + else + std::cout << "configuration was not available - using defaults" << std::endl; + + setFullscreen(config.getValueBOOL("fullscreen", false)); + setResolution(config.getValueINT("height", 768), + config.getValueINT("width", 1024)); + setNumberOfPlanets( config.getValueINT("numberOfPlanets", 6)); + setNumberOfComputerPlayers( config.getValueINT("numberOfComputerPlayers", 1)); +} + +void +Settings::setResolution( int width, int height ) { + screenWidth = width; + screenHeight = height; + gameWidth = height; + gameHeight = height; + gameOffsetX = ( width - height ) / 2; +} + +void +Settings::store() +{ + if (config.save()) + std::cout << "Setting saved successfully." << std::endl; + else + std::cout << "Setting could not be saved." << std::endl; +} Copied: branches/autoconf-2007-03-26-thebohemian/src/settings.h (from rev 13, branches/autoconf-2007-03-26-thebohemian/src/config.h) =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/settings.h (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/src/settings.h 2007-04-01 18:42:18 UTC (rev 14) @@ -0,0 +1,45 @@ +// Copyright 2005 by Anthony Liekens an...@li... + +#ifndef SETTINGS_H +#define SETTINGS_H + +#include "timer.h" +#include "readconf.h" + +#include <vector> +#include <string> + +class Settings { +private: + int screenWidth, screenHeight, gameWidth, gameHeight, gameOffsetX; + bool fullscreen; + + int numberOfPlanets; + int numberOfComputerPlayers; + + Config& config; + +public: + Settings(); + void setFullscreen( bool b ) { fullscreen = b; } + bool getFullscreen() { return fullscreen; } + + void setResolution(int, int); + int getScreenWidth() { return screenWidth; } + int getScreenHeight() { return screenHeight; } + int getGameWidth() { return gameWidth; } + int getGameHeight() { return gameHeight; } + int getGameOffsetX() { return gameOffsetX; } + + int getNumberOfPlanets() { return numberOfPlanets; } + int setNumberOfPlanets(int p) { numberOfPlanets = p; } + + int getNumberOfComputerPlayers() { return numberOfComputerPlayers; } + int setNumberOfComputerPlayers(int p) { numberOfComputerPlayers = p; } + + void store(); +}; + +static Settings settings; + +#endif Modified: branches/autoconf-2007-03-26-thebohemian/src/ships.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/ships.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,9 +1,11 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <iostream> +#include <SDL/SDL_gfxPrimitives.h> + #include "ships.h" #include "extensions.h" -#include <SDL_gfxPrimitives.h> -#include <iostream> +#include "timer.h" /* ##### SHIP ##### */ @@ -97,8 +99,8 @@ } else { double direction = getDirection(); Coordinate head = Coordinate( locx + 5.0 * cos( direction ), locy + 5.0 * sin( direction ) ); - Coordinate leftTip = Coordinate( locx + 2.0 * cos( direction + PI / 3.0 ), locy + 2.0 * sin( direction + PI / 3.0 ) ); - Coordinate rightTip = Coordinate( locx + 2.0 * cos( direction - PI / 3.0 ), locy + 2.0 * sin( direction - PI / 3.0 ) ); + Coordinate leftTip = Coordinate( locx + 2.0 * cos( direction + M_PI / 3.0 ), locy + 2.0 * sin( direction + M_PI / 3.0 ) ); + Coordinate rightTip = Coordinate( locx + 2.0 * cos( direction - M_PI / 3.0 ), locy + 2.0 * sin( direction - M_PI / 3.0 ) ); aalineRGBA( screen, leftTip.getX(), leftTip.getY(), head.getX(), head.getY(), red, green, blue, 255 ); aalineRGBA( screen, rightTip.getX(), rightTip.getY(), head.getX(), head.getY(), red, green, blue, 255 ); aalineRGBA( screen, rightTip.getX(), rightTip.getY(), leftTip.getX(), leftTip.getY(), red, green, blue, 255 ); Modified: branches/autoconf-2007-03-26-thebohemian/src/ships.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/ships.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/ships.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,15 +3,19 @@ #ifndef SHIPS_H #define SHIPS_H +#include <list> +using namespace std; + +#include <SDL/SDL.h> + +#include "coordinate.h" #include "players.h" #include "planets.h" #include "actions.h" #include "selection.h" -#include <SDL/SDL.h> -#include <list> -using namespace std; class Planet; +class Player; class Ship { public: @@ -28,8 +32,8 @@ // for movement purposes only - Coordinate fromLocation, toLocation; - Uint32 fromTime, toTime; + Coordinate fromLocation, toLocation; + Uint32 fromTime, toTime; public: Ship( Player*, Planet* ); Modified: branches/autoconf-2007-03-26-thebohemian/src/stars.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/stars.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/stars.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,7 +1,8 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <SDL/SDL_gfxPrimitives.h> + #include "stars.h" -#include "config.h" // ##### STAR METHODS ##### Modified: branches/autoconf-2007-03-26-thebohemian/src/stars.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/stars.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/stars.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,12 +3,12 @@ #ifndef STARS_H #define STARS_H -#include <SDL_gfxPrimitives.h> -#include "coordinate.h" -#include <SDL/SDL.h> #include <vector> -#include <stdlib.h> +#include <SDL/SDL.h> + +#include "coordinate.h" + class Star { private: Coordinate c; Modified: branches/autoconf-2007-03-26-thebohemian/src/timer.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/timer.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/timer.h 2007-04-01 18:42:18 UTC (rev 14) @@ -26,4 +26,6 @@ }; +static Timer timer; + #endif Modified: branches/autoconf-2007-03-26-thebohemian/src/universe.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/universe.cpp 2007-04-01 18:42:18 UTC (rev 14) @@ -1,8 +1,15 @@ // Copyright 2005 by Anthony Liekens an...@li... +#include <iostream> +#include <SDL/SDL_gfxPrimitives.h> + #include "universe.h" -#include <SDL_gfxPrimitives.h> -#include <iostream> +#include "planets.h" +#include "stars.h" +#include "messages.h" +#include "actions.h" +#include "timer.h" +#include "settings.h" Universe::Universe() { stars = new Stars( 100 ); Modified: branches/autoconf-2007-03-26-thebohemian/src/universe.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/src/universe.h 2007-04-01 15:00:42 UTC (rev 13) +++ branches/autoconf-2007-03-26-thebohemian/src/universe.h 2007-04-01 18:42:18 UTC (rev 14) @@ -3,8 +3,6 @@ #ifndef UNIVERSE_H #define UNIVERSE_H -#include "stars.h" -#include "planets.h" #include "actions.h" #include "animations.h" #include "messages.h" @@ -12,8 +10,6 @@ class Stars; class Planet; class Planets; -class AnimationQueue; -class Messages; class Universe { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-04-01 15:00:44
|
Revision: 13 http://qonk.svn.sourceforge.net/qonk/?rev=13&view=rev Author: thebohemian Date: 2007-04-01 08:00:42 -0700 (Sun, 01 Apr 2007) Log Message: ----------- - moved sources from root directory into src - moved font.tff into data directory Added Paths: ----------- branches/autoconf-2007-03-26-thebohemian/Makefile.manual branches/autoconf-2007-03-26-thebohemian/data/ branches/autoconf-2007-03-26-thebohemian/data/font.ttf branches/autoconf-2007-03-26-thebohemian/src/ branches/autoconf-2007-03-26-thebohemian/src/ReadConf.cpp branches/autoconf-2007-03-26-thebohemian/src/ReadConf.h branches/autoconf-2007-03-26-thebohemian/src/actions.cpp branches/autoconf-2007-03-26-thebohemian/src/actions.h branches/autoconf-2007-03-26-thebohemian/src/animations.cpp branches/autoconf-2007-03-26-thebohemian/src/animations.h branches/autoconf-2007-03-26-thebohemian/src/config.cpp branches/autoconf-2007-03-26-thebohemian/src/config.h branches/autoconf-2007-03-26-thebohemian/src/coordinate.cpp branches/autoconf-2007-03-26-thebohemian/src/coordinate.h branches/autoconf-2007-03-26-thebohemian/src/extensions.cpp branches/autoconf-2007-03-26-thebohemian/src/extensions.h branches/autoconf-2007-03-26-thebohemian/src/fonts.cpp branches/autoconf-2007-03-26-thebohemian/src/fonts.h branches/autoconf-2007-03-26-thebohemian/src/main.cpp branches/autoconf-2007-03-26-thebohemian/src/messages.cpp branches/autoconf-2007-03-26-thebohemian/src/messages.h branches/autoconf-2007-03-26-thebohemian/src/planets.cpp branches/autoconf-2007-03-26-thebohemian/src/planets.h branches/autoconf-2007-03-26-thebohemian/src/players.cpp branches/autoconf-2007-03-26-thebohemian/src/players.h branches/autoconf-2007-03-26-thebohemian/src/selection.cpp branches/autoconf-2007-03-26-thebohemian/src/selection.h branches/autoconf-2007-03-26-thebohemian/src/ships.cpp branches/autoconf-2007-03-26-thebohemian/src/ships.h branches/autoconf-2007-03-26-thebohemian/src/stars.cpp branches/autoconf-2007-03-26-thebohemian/src/stars.h branches/autoconf-2007-03-26-thebohemian/src/timer.cpp branches/autoconf-2007-03-26-thebohemian/src/timer.h branches/autoconf-2007-03-26-thebohemian/src/universe.cpp branches/autoconf-2007-03-26-thebohemian/src/universe.h Removed Paths: ------------- branches/autoconf-2007-03-26-thebohemian/Makefile branches/autoconf-2007-03-26-thebohemian/ReadConf.cpp branches/autoconf-2007-03-26-thebohemian/ReadConf.h branches/autoconf-2007-03-26-thebohemian/actions.cpp branches/autoconf-2007-03-26-thebohemian/actions.h branches/autoconf-2007-03-26-thebohemian/animations.cpp branches/autoconf-2007-03-26-thebohemian/animations.h branches/autoconf-2007-03-26-thebohemian/config.cpp branches/autoconf-2007-03-26-thebohemian/config.h branches/autoconf-2007-03-26-thebohemian/coordinate.cpp branches/autoconf-2007-03-26-thebohemian/coordinate.h branches/autoconf-2007-03-26-thebohemian/extensions.cpp branches/autoconf-2007-03-26-thebohemian/extensions.h branches/autoconf-2007-03-26-thebohemian/font.ttf branches/autoconf-2007-03-26-thebohemian/fonts.cpp branches/autoconf-2007-03-26-thebohemian/fonts.h branches/autoconf-2007-03-26-thebohemian/main.cpp branches/autoconf-2007-03-26-thebohemian/messages.cpp branches/autoconf-2007-03-26-thebohemian/messages.h branches/autoconf-2007-03-26-thebohemian/planets.cpp branches/autoconf-2007-03-26-thebohemian/planets.h branches/autoconf-2007-03-26-thebohemian/players.cpp branches/autoconf-2007-03-26-thebohemian/players.h branches/autoconf-2007-03-26-thebohemian/selection.cpp branches/autoconf-2007-03-26-thebohemian/selection.h branches/autoconf-2007-03-26-thebohemian/ships.cpp branches/autoconf-2007-03-26-thebohemian/ships.h branches/autoconf-2007-03-26-thebohemian/stars.cpp branches/autoconf-2007-03-26-thebohemian/stars.h branches/autoconf-2007-03-26-thebohemian/timer.cpp branches/autoconf-2007-03-26-thebohemian/timer.h branches/autoconf-2007-03-26-thebohemian/universe.cpp branches/autoconf-2007-03-26-thebohemian/universe.h Deleted: branches/autoconf-2007-03-26-thebohemian/Makefile =================================================================== --- branches/autoconf-2007-03-26-thebohemian/Makefile 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/Makefile 2007-04-01 15:00:42 UTC (rev 13) @@ -1,58 +0,0 @@ -PREFIX=/usr/local/share/games -BIN=/usr/local/bin - -CXX=g++ -CFLAGS=`sdl-config --cflags` -O3 -LIBS=`sdl-config --libs` -lSDL_ttf -lSDL_gfx - -WCC=i586-mingw32msvc-g++ -WC=i586-mingw32msvc-gcc -WCFLAGS=-c -WLDFLAGS=-lmingw32 -lSDLmain -lSDL -lSDL_ttf -lSDL_gfx -WLIBS=-lmingw32 -lSDLmain -lSDL -lSDL_ttf -lSDL_gfx - -OBJECTS=extensions.o coordinate.o stars.o planets.o selection.o ships.o main.o actions.o players.o universe.o animations.o fonts.o messages.o timer.o config.o ReadConf.o - -all: qonk - -qonk: $(OBJECTS) - $(CXX) $(CFLAGS) $(LIBS) $(OBJECTS) -o qonk - -windows: wob - $(WCC) $(WLDFLAGS) $(OBJECTS) -o qonk.exe $(WLIBS) - -wob: - $(WCC) $(WCFLAGS) *.cpp - -.cpp.o: - $(CXX) $(CFLAGS) -c $< - -clean: - @rm -vf *.o *~ qonk screenshot.bmp DEADJOE - -dist: clean - mkdir -p qonk/ - cp *.cpp qonk/ - cp *.h qonk/ - cp Makefile qonk/ - cp TODO qonk/ - cp README qonk/ - cp COPYING qonk/ - cp font.ttf qonk/ - cp qonk.conf qonk/ - tar -cvzf ../qonk.tar.gz qonk/ - rm -rf qonk/ - -install: all - mkdir -p $(PREFIX)/qonk - cp qonk $(PREFIX)/qonk/ - cp font.ttf $(PREFIX)/qonk/ - cp qonk.conf $(PREFIX)/qonk/ - echo "cd $(PREFIX)/qonk" > $(BIN)/qonk - echo "./qonk" >> $(BIN)/qonk - chmod +x $(BIN)/qonk - - -uninstall: - rm -rf $(PREFIX)/qonk - rm $(BIN)/qonk Copied: branches/autoconf-2007-03-26-thebohemian/Makefile.manual (from rev 12, branches/autoconf-2007-03-26-thebohemian/Makefile) =================================================================== --- branches/autoconf-2007-03-26-thebohemian/Makefile.manual (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/Makefile.manual 2007-04-01 15:00:42 UTC (rev 13) @@ -0,0 +1,58 @@ +PREFIX=/usr/local/share/games +BIN=/usr/local/bin + +CXX=g++ +CFLAGS=`sdl-config --cflags` -O3 +LIBS=`sdl-config --libs` -lSDL_ttf -lSDL_gfx + +WCC=i586-mingw32msvc-g++ +WC=i586-mingw32msvc-gcc +WCFLAGS=-c +WLDFLAGS=-lmingw32 -lSDLmain -lSDL -lSDL_ttf -lSDL_gfx +WLIBS=-lmingw32 -lSDLmain -lSDL -lSDL_ttf -lSDL_gfx + +OBJECTS=extensions.o coordinate.o stars.o planets.o selection.o ships.o main.o actions.o players.o universe.o animations.o fonts.o messages.o timer.o config.o ReadConf.o + +all: qonk + +qonk: $(OBJECTS) + $(CXX) $(CFLAGS) $(LIBS) $(OBJECTS) -o qonk + +windows: wob + $(WCC) $(WLDFLAGS) $(OBJECTS) -o qonk.exe $(WLIBS) + +wob: + $(WCC) $(WCFLAGS) *.cpp + +.cpp.o: + $(CXX) $(CFLAGS) -c $< + +clean: + @rm -vf *.o *~ qonk screenshot.bmp DEADJOE + +dist: clean + mkdir -p qonk/ + cp *.cpp qonk/ + cp *.h qonk/ + cp Makefile qonk/ + cp TODO qonk/ + cp README qonk/ + cp COPYING qonk/ + cp font.ttf qonk/ + cp qonk.conf qonk/ + tar -cvzf ../qonk.tar.gz qonk/ + rm -rf qonk/ + +install: all + mkdir -p $(PREFIX)/qonk + cp qonk $(PREFIX)/qonk/ + cp font.ttf $(PREFIX)/qonk/ + cp qonk.conf $(PREFIX)/qonk/ + echo "cd $(PREFIX)/qonk" > $(BIN)/qonk + echo "./qonk" >> $(BIN)/qonk + chmod +x $(BIN)/qonk + + +uninstall: + rm -rf $(PREFIX)/qonk + rm $(BIN)/qonk Deleted: branches/autoconf-2007-03-26-thebohemian/ReadConf.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/ReadConf.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/ReadConf.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,91 +0,0 @@ -#include "ReadConf.h" - -Config::Config( const std::string& configFileName ){ - std::ifstream file( configFileName.c_str() ); - while (!file.eof()){ - std::string line; - getline( file, line ); - std::string::size_type loc = line.find( "=", 0 ); - if( line[0] != '#' ) - if( loc != std::string::npos ) { - std::string parameter = stripWhiteSpace( line.substr( 0, loc ) ); - std::string value = stripWhiteSpace( line.substr( loc + 1 ) ); - data[ parameter ] = value; - } - } - file.close(); - std::cout << "config file read" << std::endl; -} - -std::string -Config::getValue( const std::string& parameter ) const { - std::map< std::string, std::string >::const_iterator i = data.find( parameter ); - if( i != data.end() ) - return i->second; - else - return ""; -} - -bool -Config::getValueBOOL( const std::string& parameter ) const { - std::string s = getValue(parameter); - return str2bool(s); -} - -int -Config::getValueINT( const std::string& parameter ) const { - std::string s = getValue(parameter); - return str2int(s); -} - -void -Config::print() const { - for( std::map< std::string, std::string >::const_iterator i = data.begin(); i != data.end(); i++ ) - std::cout << "'" << i->first << "' => '" << i->second << "'" << std::endl; -} - -bool -fileExists( const std::string& fileName ) { - std::ifstream infile( fileName.c_str() ); - bool result = infile.good(); - infile.close(); - return result; -} - -void -createFile( const std::string& fileName, std::vector< std::string > content ){ - if( !fileExists( fileName ) ){ - std::ofstream outfile( fileName.c_str() ); - for( std::vector< std::string >::const_iterator iter = content.begin(); iter != content.end(); iter++ ) { - outfile.write( (*iter).data(), (*iter).size() ); - outfile.write( "\n", 1 ); - } - outfile.close(); - } -} - -bool -str2bool( const std::string& s ) { - if (s == std::string("true")) { - return true; - } else if (s == std::string("false")){ - return false; - } else { - std::cerr << "Invalid bool type"; - } -} - -int -str2int( const std::string& s ) { - std::istringstream i(s); - int x; - i>>x; - return x; -} - -std::string -stripWhiteSpace( const std::string& original ) { - int begin = original.find_first_not_of( " " ); - int end = original.find_last_not_of( " " ); - return original.substr( begin, end - begin + 1 ); -} Deleted: branches/autoconf-2007-03-26-thebohemian/ReadConf.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/ReadConf.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/ReadConf.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,36 +0,0 @@ -// ReadConf.h -// Class for reading named values from configuration files -// Troels Kofoed Jacobsen, Mar 19 2007, tkj...@gm... -// Licensed under GPLv2 -#ifndef READCONF_H -#define READCONF_H - -#include <string> -#include <map> -#include <vector> -#include <fstream> -#include <iostream> -#include <cctype> -#include <sstream> - -class Config { -public: - Config( const std::string& fileName ); - - std::string getValue( const std::string& parameter ) const; - bool getValueBOOL( const std::string& parameter ) const; - int getValueINT( const std::string& parameter ) const; - - void print() const; - -private: - std::map< std::string, std::string > data; -}; - -bool fileExists( const std::string& ); -void createFile( const std::string&, std::vector< std::string > ); -bool str2bool(const std::string& ); -int str2int(const std::string& ); -std::string stripWhiteSpace( const std::string& ); - -#endif Deleted: branches/autoconf-2007-03-26-thebohemian/actions.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/actions.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/actions.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,74 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "actions.h" - -#include "config.h" -#include <iostream> - -// ##### ACTION ##### - -Action::Action() { - actionID = 0; -} - -void -Action::setActionQueue( ActionQueue* actionQueue ) { - this->actionQueue = actionQueue; -} - -ActionQueue* -Action::getActionQueue() const { - return actionQueue; -} - -// ##### ACTIONQUEUE ##### - -ActionQueue::ActionQueue() { - clear(); - time = 0; -} - -void -ActionQueue::scheduleAction( Uint32 time, Action* action ) { - if( this->time > time ) { - std::cerr << "Action was inserted before action that has already been executed" << endl; - } - action->setActionQueue( this ); - insert( pair< Uint32, Action* >( time, action ) ); -} - -Uint32 -ActionQueue::timeOfNextEvent() { - return this->begin()->first; -} - -void -ActionQueue::executeNextEvent() { - time = this->begin()->first; - Action* a = this->begin()->second; -// if( time > timer.getTime() ) { -// SDL_Delay( time - timer.getTime() ); -// } - a->execute( time ); - erase( this->begin() ); - delete a; -} - -void -ActionQueue::executeAllEvents() { - while( size() > 0 ) { - executeNextEvent(); - } -} - -void ActionQueue::executeEventsBefore( Uint32 time ) { - while( ( size() > 0 ) && ( timeOfNextEvent() < time ) ) { - executeNextEvent(); - } -} - -void -ActionQueue::executePastEvents() { - executeEventsBefore( timer.getTime() ); -} - Deleted: branches/autoconf-2007-03-26-thebohemian/actions.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/actions.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/actions.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,41 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef ACTIONS_H -#define ACTIONS_H - -#include <SDL/SDL.h> -#include <map> -using namespace std; - -class ActionQueue; - -class Action { -private: - ActionQueue* actionQueue; -protected: - int actionID; -public: - Action(); - virtual void execute( const Uint32& time ) = 0; - virtual ~Action() {} - void setActionQueue( ActionQueue* actionQueue ); - ActionQueue* getActionQueue() const; - int getActionID() { return actionID; } -}; - -class ActionQueue : public multimap< Uint32, Action* > { -private: - Uint32 time; -public: - ActionQueue(); - void scheduleAction( Uint32 time, Action* action ); - - Uint32 timeOfNextEvent(); - - void executeNextEvent(); - void executeAllEvents(); - void executeEventsBefore( Uint32 time ); - void executePastEvents(); -}; - -#endif Deleted: branches/autoconf-2007-03-26-thebohemian/animations.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/animations.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/animations.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,40 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "animations.h" -#include <SDL_gfxPrimitives.h> - -#include <iostream> - -void -AnimationQueue::render( SDL_Surface* screen ) { - for( iterator i = begin(); i != end(); i++ ) { - Animation* animation = (Animation*)( i->second ); - animation->render( screen ); - } -} - -SonarAnimation::SonarAnimation() { -} - -SonarAnimation::SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle ) { - this->circle = circle; - this->planet = planet; - r = ( color & 0xFF0000 ) >> 16; - g = ( color & 0x00FF00 ) >> 8; - b = ( color & 0x0000FF ); -// this->color = color; - this->size = size; - this->startTime = startTime; - this->endTime = endTime; -} - -void -SonarAnimation::render( SDL_Surface* screen ) { - Uint32 currentTime = timer.getTime(); - if( ( currentTime > startTime ) && ( currentTime < endTime ) ) { - double percentage = (double)( currentTime - startTime ) / ( endTime - startTime ); - filledCircleRGBA( screen, planet->getLocation().getXMapped(), planet->getLocation().getYMapped(), (int)( size * sin( percentage * PI ) ), r, g, b, (int)( ( 255 - 255 * percentage ) * 0.05 ) ); - if( circle ) - aacircleRGBA( screen, planet->getLocation().getXMapped(), planet->getLocation().getYMapped(), (int)( size * sin( percentage * PI ) ), r, g, b, 255 - (int)( 255 * percentage ) ); - } -} Deleted: branches/autoconf-2007-03-26-thebohemian/animations.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/animations.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/animations.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,39 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef ANIMATIONS_H -#define ANIMATIONS_H - -#include "actions.h" -#include "coordinate.h" -#include "config.h" -#include "planets.h" - -#include <math.h> - -class Planet; - -class Animation : public Action { -public: - void execute( const Uint32& time ) {} - virtual void render( SDL_Surface* screen ) = 0; -}; - -class AnimationQueue : public ActionQueue { -public: - void render( SDL_Surface* screen ); -}; - -class SonarAnimation : public Animation { -private: - bool circle; - Planet* planet; - Uint32 startTime, endTime; - Uint8 r, g, b; - int size; -public: - SonarAnimation(); - SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle = false ); - void render( SDL_Surface* screen ); -}; - -#endif Deleted: branches/autoconf-2007-03-26-thebohemian/config.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/config.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/config.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,76 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "config.h" -#include <iostream> - -class Config; - -Settings::Settings() { - //setResolution( 800, 600 ); - //setFullscreen( true ); - - //Create configuration file if it does not exist - if (!fileExists("qonk.conf")){ - vector<string> v; - v.push_back("# Qonk configuration file "); - v.push_back("# Format: entry = value (The spaces is optional)\n"); - v.push_back("# Window"); - v.push_back("fullscreen = true"); - v.push_back("width = 1024"); - v.push_back("height = 768\n"); - v.push_back("# Settings for first round"); - v.push_back("numberOfPlanets = 6"); - v.push_back("numberOfComputerPlayers = 1"); - createFile("qonk.conf",v); - } - Config config("qonk.conf"); - //Read settings form qonk.conf - bool fs = config.getValueBOOL("fullscreen"); - int h = config.getValueINT("height"); - int w = config.getValueINT("width"); - setResolution(w, h ); - setFullscreen( fs ); -} - -Settings::Settings(int w, int h, bool fs) { - setResolution( w, h ); - setFullscreen( fs ); -} - -void -Settings::setResolution( int width, int height ) { - screenWidth = width; - screenHeight = height; - gameWidth = height; - gameHeight = height; - gameOffsetX = ( width - height ) / 2; -} - -void -Settings::setFullscreen( bool b ) { - fullscreen = b; -} - -int Settings::getScreenWidth() { - return screenWidth; -} - -int Settings::getScreenHeight() { - return screenHeight; -} - -int Settings::getGameWidth() { - return gameWidth; -} - -int Settings::getGameHeight() { - return gameHeight; -} - -int Settings::getGameOffsetX() { - return gameOffsetX; -} - -bool Settings::getFullscreen() { - return fullscreen; -} Deleted: branches/autoconf-2007-03-26-thebohemian/config.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/config.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/config.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,35 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef CONFIG_H -#define CONFIG_H - -#define PI 3.14159265 - -#include "timer.h" -#include "ReadConf.h" -#include <vector> -#include <string> - -static Timer timer; - -class Settings { -private: - int screenWidth, screenHeight, gameWidth, gameHeight, gameOffsetX; - bool fullscreen; -public: - Settings(); - Settings(int, int, bool); - void setResolution( int width, int height ); - void setFullscreen( bool b ); - int getScreenWidth(); - int getScreenHeight(); - int getGameWidth(); - int getGameHeight(); - int getGameOffsetX(); - bool getFullscreen(); -}; - -static Settings settings; -//static Config config("qonk.conf"); - -#endif Deleted: branches/autoconf-2007-03-26-thebohemian/coordinate.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/coordinate.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/coordinate.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,64 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "coordinate.h" - -#include "config.h" -#include <math.h> - -Coordinate::Coordinate() { - x = 0; - y = 0; -} - -Coordinate::Coordinate( double x, double y ) { - this->x = x; - this->y = y; -} - -void -Coordinate::setX( double x ) { - this->x = x; -} - -void -Coordinate::setY( double y ) { - this->y = y; -} - -void -Coordinate::setXMapped( int x ) { - this->x = ( (double)x - settings.getGameOffsetX() ) / settings.getGameWidth(); -} - -void -Coordinate::setYMapped( int y ) { - this->y = (double)y / settings.getGameHeight(); -} - -double -Coordinate::getX() const { - return x; -} - -double -Coordinate::getY() const { - return y; -} - -int -Coordinate::getXMapped() const { - return settings.getGameOffsetX() + ( int )( settings.getGameWidth() * x ); -} - -int -Coordinate::getYMapped() const { - return ( int )( settings.getGameHeight() * y ); -} - -double -Coordinate::distance( const Coordinate& c ) const { - double dx = c.getX() - getX(); - double dy = c.getY() - getY(); - return sqrt( dx * dx + dy * dy ); -} - Deleted: branches/autoconf-2007-03-26-thebohemian/coordinate.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/coordinate.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/coordinate.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,27 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef COORDINATE_H -#define COORDINATE_H - -class Coordinate { -private: - double x, y; -public: - Coordinate(); - Coordinate( double x, double y ); - - void setX( double x ); - void setY( double y ); - void setXMapped( int x ); - void setYMapped( int y ); - - double getX() const; - double getY() const; - int getXMapped() const; - int getYMapped() const; - - double distance( const Coordinate& c ) const; - -}; - -#endif Copied: branches/autoconf-2007-03-26-thebohemian/data/font.ttf (from rev 12, branches/autoconf-2007-03-26-thebohemian/font.ttf) =================================================================== (Binary files differ) Deleted: branches/autoconf-2007-03-26-thebohemian/extensions.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/extensions.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/extensions.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,135 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "extensions.h" -#include <SDL_gfxPrimitives.h> - -void -alphaBlend( SDL_Surface* surface, Uint8 alpha ) { - if( alpha == 0 ) { - for( int x = 0; x < surface->w; x++ ) - for( int y = 0; y < surface->h; y++ ) { - Uint32 *bufp; - bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; - if( *bufp != 0 ) - *bufp &= 0x00ffffff; - } - } if( alpha != 255 ) { - for( int x = 0; x < surface->w; x++ ) - for( int y = 0; y < surface->h; y++ ) { - Uint32 *bufp; - bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; - if( *bufp != 0 ) { - // seperate RGB from A, update A for new value, OR them together again - Uint32 color = ( *bufp & 0x00ffffff ) | ( ( *bufp >> 24 ) * alpha >> 8 ) << 24; - *bufp = color; - } - } - } -} - -void -drawSelector( SDL_Surface *screen, Sint16 x1, Sint16 y1, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ) { - hlineRGBA( screen, x1, x1 + 2, y1, R, G, B, 255 ); - hlineRGBA( screen, x1 + width - 2, x1 + width, y1, R, G, B, 255 ); - hlineRGBA( screen, x1, x1 + 2, y1 + height, R, G, B, 255 ); - hlineRGBA( screen, x1 + width - 2, x1 + width, y1 + height, R, G, B, 255 ); - vlineRGBA( screen, x1, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( screen, x1, y1 + height, y1 + height - 2, R, G, B, 255 ); - vlineRGBA( screen, x1 + width, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( screen, x1 + width, y1 + height, y1 + height - 2, R, G, B, 255 ); -} - -void -drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint8 R, Uint8 G, Uint8 B ) { - filledCircleRGBA( screen, x, y, size + 2, 0, 0, 0, 128 ); - filledCircleRGBA( screen, x, y, size, R, G, B, 255 ); - aacircleRGBA( screen, x, y, size, R, G, B, 255 ); - filledEllipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); - aaellipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); -} - -void -drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint32 color ) { - drawPlanet( screen, x, y, size, getRed( color ), getGreen( color ), getBlue( color ) ); -} - -double -frand() { - return (double)rand() / RAND_MAX; -} - -double -frand( double max ) { - return max * frand(); -} - -Uint32 HSVtoRGB( float h, float s, float v ) -{ - int i; - float f, p, q, t, r, g, b; - - if( s == 0 ) { - - // achromatic (grey) - r = g = b = v; - - } else { - - h /= 60; // sector 0 to 5 - i = (int)h; - f = h - i; // factorial part of h - p = v * ( 1 - s ); - q = v * ( 1 - s * f ); - t = v * ( 1 - s * ( 1 - f ) ); - - switch( i ) { - case 0: - r = v; - g = t; - b = p; - break; - case 1: - r = q; - g = v; - b = p; - break; - case 2: - r = p; - g = v; - b = t; - break; - case 3: - r = p; - g = q; - b = v; - break; - case 4: - r = t; - g = p; - b = v; - break; - default: // case 5: - r = v; - g = p; - b = q; - break; - } - - } - - return 256 * 256 * (int)( 255 * r ) + 256 * (int)( 255 * g ) + (int)( 255 * b ); - -} - -Uint8 getRed( Uint32 color ) { - return ( color & 0xFF0000 ) >> 16; -} - -Uint8 getGreen( Uint32 color ) { - return ( color & 0x00FF00 ) >> 8; -} - -Uint8 getBlue( Uint32 color ) { - return color & 0x0000FF; -} - Deleted: branches/autoconf-2007-03-26-thebohemian/extensions.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/extensions.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/extensions.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,24 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef EXTENSIONS_H -#define EXTENSIONS_H - -#include "config.h" -#include <SDL/SDL.h> -#include <sstream> -using namespace std; - -void alphaBlend( SDL_Surface* surface, Uint8 alpha ); - -void drawSelector( SDL_Surface *screen, Sint16 x1, Sint16 y1, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ); -void drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint8 R, Uint8 G, Uint8 B ); -void drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint32 color ); -double frand(); -double frand( double max ); -Uint32 HSVtoRGB( float h, float s, float v ); - -Uint8 getRed( Uint32 color ); -Uint8 getGreen( Uint32 color ); -Uint8 getBlue( Uint32 color ); - -#endif Deleted: branches/autoconf-2007-03-26-thebohemian/font.ttf =================================================================== (Binary files differ) Deleted: branches/autoconf-2007-03-26-thebohemian/fonts.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/fonts.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/fonts.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,67 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "fonts.h" - -#include "extensions.h" - -Font::Font( char* fileName, int size ) { - font = TTF_OpenFont( fileName, size ); - if ( font == NULL ) { - cerr << "Couldn't load " << size << "pt font from " << fileName << ": " << SDL_GetError() << endl; - exit( 1 ); - } - TTF_SetFontStyle( font, TTF_STYLE_NORMAL ); -} - -void -Font::render( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a ) { - SDL_Color color = { r, g, b, a }; - SDL_Surface* textSurface = TTF_RenderText_Blended( font, text, color ); - if ( textSurface != NULL ) { - SDL_Rect dstrect; - dstrect.x = x; - dstrect.y = y; - dstrect.w = textSurface->w; - dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); - SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); - SDL_FreeSurface( textSurface ); - } -} - -void -Font::renderCenterJustified( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a ) { - SDL_Color color = { r, g, b, 0 }; - SDL_Surface* textSurface = TTF_RenderText_Blended( font, text, color ); - if ( textSurface != NULL ) { - SDL_Rect dstrect; - dstrect.x = x - textSurface->w / 2; - dstrect.y = y - textSurface->h / 2; - dstrect.w = textSurface->w; - dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); - SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); - SDL_FreeSurface( textSurface ); - } -} - -void -Font::renderRightJustified( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a ) { - SDL_Color color = { r, g, b, 0 }; - SDL_Surface* textSurface = TTF_RenderText_Blended( font, text, color ); - if ( textSurface != NULL ) { - SDL_Rect dstrect; - dstrect.x = x - textSurface->w; - dstrect.y = y; - dstrect.w = textSurface->w; - dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); - SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); - SDL_FreeSurface( textSurface ); - } -} - -int -Font::getHeight() { - return TTF_FontHeight( font ); -} Deleted: branches/autoconf-2007-03-26-thebohemian/fonts.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/fonts.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/fonts.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,24 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef FONTS_H -#define FONTS_H - -#include <SDL/SDL.h> -#include <SDL/SDL_ttf.h> -#include <iostream> -using namespace std; - -class Font { -private: - TTF_Font* font; -public: - Font( char* fileName, int size ); - - void render( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255 ); - void renderCenterJustified( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255 ); - void renderRightJustified( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255 ); - - int getHeight(); -}; - -#endif Deleted: branches/autoconf-2007-03-26-thebohemian/main.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/main.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/main.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,318 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "coordinate.h" -#include "stars.h" -#include "planets.h" -#include "selection.h" -#include "players.h" -#include "universe.h" -#include "fonts.h" -#include "ReadConf.h" -#include "config.h" - -#include <SDL_gfxPrimitives.h> -#include <SDL/SDL.h> -#include <SDL/SDL_ttf.h> -#include <math.h> - -#include <iostream> -#include <iomanip> -#include <sstream> -#include <vector> -#include <string> -#include <list> - -Font* font; -Uint32 FPStimer, FPScounter; -double FPS; - -enum States { PLAYING, LOST, WON }; -States state; - -void render( SDL_Surface* screen, Universe* universe, Players* players ) { - - boxRGBA( screen, 0, 0, settings.getScreenWidth(), settings.getScreenHeight(), 0, 0, 0, 255 ); - - universe->renderBackground( screen ); - players->render( screen ); - universe->renderForeground( screen ); - - stringstream s; - s << timer.getTimeMMSSHH(); - - FPScounter++; - if( SDL_GetTicks() - FPStimer >= 1000 ) { - if( FPS == 0 ) - FPS = ( FPS + 1000.0 * FPScounter / ( SDL_GetTicks() - FPStimer ) ) / 2; - else - FPS = 1000.0 * FPScounter / ( SDL_GetTicks() - FPStimer ); - FPStimer = SDL_GetTicks(); - FPScounter = 0; - } - s << " (" << setiosflags(ios::fixed) << setprecision(2) << FPS << "FPS)"; - font->render( screen, 13, settings.getGameHeight() - 30, s.str().c_str(), 0x80, 0x80, 0x80 ); - - SDL_UpdateRect(screen, 0, 0, settings.getScreenWidth(), settings.getScreenHeight() ); - -} - -void changeScreen(SDL_Surface **screen) { - - if( settings.getFullscreen() ) - *screen = SDL_SetVideoMode( settings.getScreenWidth(), settings.getScreenHeight(), 32, SDL_SWSURFACE | SDL_FULLSCREEN ); - else - *screen = SDL_SetVideoMode( settings.getScreenWidth(), settings.getScreenHeight(), 32, SDL_SWSURFACE ); -} - - -int main(int argc, char** argv) { - -/* bool fullscreen = config.getValueBOOL("fullscreen"); - int h = config.getValueINT("height"); - int w = config.getValueINT("width"); - - settings.setResolution( w, h ); - settings.setFullscreen( fullscreen ); -*/ - bool FirstRun = true; - - int numberOfPlanets; - int numberOfComputerPlayers; - - bool NextRound = true; - while (NextRound){ - state = PLAYING; - - if (FirstRun){ - FirstRun=false; - if( argc != 3 ) { - //cerr << "Usage: " << argv[ 0 ] << " numberOfPlanets numberOfComputerPlayers" << endl; - //cerr << "Setting to default 6 planets and 1 computer player" << endl; -// numberOfPlanets = config.getValueINT("numberOfPlanets"); -// numberOfComputerPlayers = config.getValueINT("numberOfComputerPlayers"); - numberOfPlanets = 6; - numberOfComputerPlayers = 1; - } else { - numberOfPlanets = atoi( argv[ 1 ] ); - numberOfComputerPlayers = atoi( argv[ 2 ] ); - } - if( numberOfPlanets <= 1 ) { - cerr << "Resetting to least of 2 planets" << endl; - numberOfPlanets = 2; - } - if( numberOfComputerPlayers > numberOfPlanets - 1 ) { - cerr << "Resetting computer players to maximum of " << numberOfPlanets - 1 << endl; - numberOfComputerPlayers = numberOfPlanets - 1; - } - if( numberOfComputerPlayers <= 1 ) { - cerr << "Resetting computer players to at least 1" << endl; - numberOfComputerPlayers = 1; - } - } - // determine next level when this was passed successfully - - int nextPlanets = numberOfPlanets + 1; - int nextComputerPlayers = numberOfComputerPlayers + 1; - if( nextPlanets == 11 ) { - int d = nextPlanets - nextComputerPlayers; - if( d != 1 ) { - nextPlanets = 10; - } - } - - /* Init SDL */ - if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO ) < 0 ) { - cerr << "Couldn't initialize SDL: " << SDL_GetError() << endl; - exit( 1 ); - } - timer.start(); - atexit( SDL_Quit ); - if ( TTF_Init() < 0 ) { - cerr << "Couldn't initialize TTF: " << SDL_GetError() << endl; - exit( 1 ); - } - atexit( TTF_Quit ); - font = new Font( "font.ttf", 18 ); - - srand( time( NULL) ); - - /* Set window title */ - SDL_WM_SetCaption( "Qonk", "Qonk" ); - - /* Initialize the display */ - SDL_Surface *screen; -// cout << settings.getGameWidth() << "+" << settings.getGameOffsetX() << endl; - - changeScreen(&screen); - - Universe* universe = new Universe( numberOfPlanets ); - - Players* players = new Players( universe ); - universe->actionQueue->scheduleAction( 1000, new UpdatePlayersStatsAction( players ) ); - - Planets::iterator planetIterator = universe->planets->begin(); - HumanPlayer* humanPlayer = new HumanPlayer( universe, &(*planetIterator), 3, 0xffffff ); - players->push_back( humanPlayer ); - planetIterator++; - - int hueCounter = rand() % 360; - int counter = 0; - do { - if( counter < numberOfComputerPlayers ) { - players->push_back( new ComputerPlayer( universe, &(*planetIterator), 3, HSVtoRGB( hueCounter, 0.9, 0.9 ) ) ); - counter++; - hueCounter = ( hueCounter + 360 / numberOfComputerPlayers ) % 360; - } else - if( !(&(*planetIterator))->getMoon() ) - players->push_back( new NeutralPlayer( universe, &(*planetIterator), 1 + rand() % 3, 0x606060 ) ); - else - players->push_back( new NeutralPlayer( universe, &(*planetIterator), 1 + rand() % 2, 0x606060 ) ); - planetIterator++; - } while( planetIterator != universe->planets->end() ); - - - Selection selection; - - int iteration = 0; - - bool showEnemyShips = false; - - bool quit = false; - - // Main loop: loop forever. - while( !quit ) { - - render( screen, universe, players ); - - if( !timer.isPaused() ) { - - // update the universe - - universe->update(); - - // let players update their states - - players->update(); - - } - - // Poll for events, and handle the ones we care about. - SDL_Event event; - while (SDL_PollEvent(&event)) { - - switch (event.type) { - - case SDL_KEYDOWN: - break; - case SDL_KEYUP: - if( event.key.keysym.sym == SDLK_p ) { - timer.pause(); - } -// if( event.key.keysym.sym == SDLK_t ) -// showEnemyShips = !showEnemyShips; - // If escape is pressed, return (and thus, quit) - if(event.key.keysym.sym == SDLK_ESCAPE){ - quit = true; - NextRound = false; - } - if(event.key.keysym.sym == SDLK_n) - if (state==WON) - quit = true; - - if(event.key.keysym.sym == SDLK_r){ - quit = true; - nextPlanets=numberOfPlanets; - nextComputerPlayers = numberOfComputerPlayers; - } - if(event.key.keysym.sym == SDLK_f){ - if(settings.getFullscreen()){ - settings.setFullscreen( false ); - } - else if(!settings.getFullscreen()){ - settings.setFullscreen( true ); - } - - changeScreen(&screen); - } - break; - case SDL_QUIT: - quit = true; - NextRound = false; - - } - - } - - if( humanPlayer->getPoints() == 0 ) { - showEnemyShips = true; - state = LOST; - } - - if( state == PLAYING ) { - bool allPlayersDead = true; - for( Players::iterator i = players->begin(); i != players->end(); i++ ) { - if( (*i)->getPlayerType() == Player::COMPUTER ) - if( ((ComputerPlayer*)(*i))->getPoints() > 0 ) - allPlayersDead = false; - } - if( allPlayersDead == true ) { - MSGwon(universe, nextPlanets, nextComputerPlayers); - state = WON; - } - } - - Uint8 *keystate = SDL_GetKeyState(NULL); - bool show = false; - if( keystate[SDLK_e] ) { - show = true; - } - if( keystate[SDLK_a] ) { - humanPlayer->selectAllPlanets(); - } - if( keystate[SDLK_s] ) { - SDL_SaveBMP( SDL_GetVideoSurface(), "screenshot.bmp" ); - } - for ( int i=SDLK_0; i<=SDLK_9; i++ ) { - if (keystate[i]) { - int sel = (i == SDLK_0) - ? 100 - : (i-SDLK_0) * 10; - humanPlayer->setFleetSelection(sel); - } - } - - for( Players::iterator i = players->begin(); i != players->end(); i++ ) { - if( (*i)->getPlayerType() == Player::COMPUTER ) - ((ComputerPlayer*)(*i))->setDisplayShips( show || showEnemyShips ); - if( (*i)->getPlayerType() == Player::NEUTRAL ) - ((NeutralPlayer*)(*i))->setDisplayShips( show || showEnemyShips ); - } - - // Keep shut for some time, not to use too much CPU - - // SDL_Delay( 20 ); - - } - - delete font; - delete universe; - delete players; - - /* // We dont want to much output to cout - if( state == LOST ) { - cout << "The AI players have kicked you out? Bastards!" << endl; - cout << "Try harder, run QONK again, with \n\n\t" << argv[ 0 ] << " " << numberOfPlanets << " " << numberOfComputerPlayers << "\n" << endl; - } else if ( state == PLAYING ) { - cout << "You gave up early?!" << endl; - cout << "Try again, run QONK again, with \n\n\t" << argv[ 0 ] << " " << numberOfPlanets << " " << numberOfComputerPlayers << "\n" << endl; - } else { - cout << "You have QONKuered the solar system! You won!" << endl; - cout << "Move on to the next level, and run QONK again with \n\n\t" << argv[ 0 ] << " " << nextPlanets << " " << nextComputerPlayers << "\n" << endl; - }*/ - - numberOfPlanets = nextPlanets; - numberOfComputerPlayers = nextComputerPlayers; - } - return 0; - -} Deleted: branches/autoconf-2007-03-26-thebohemian/messages.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/messages.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/messages.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,134 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "messages.h" - - -Message::Message( string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; - this->displayTime= displayTime; - this->r = r; - this->g = g; - this->b = b; -} - -Message::Message( string message, Uint32 displayTime, Uint32 color ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; - this->displayTime = displayTime; - this->r = getGreen( color ); - this->g = getRed( color ); - this->b = getBlue( color ); -} - -Message::Message( string message, Uint8 r, Uint8 g, Uint8 b ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; - this->displayTime= 10000; - this->r = r; - this->g = g; - this->b = b; -} - -Message::Message( string message, Uint32 color ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; - this->displayTime = 10000; - this->r = getGreen( color ); - this->g = getRed( color ); - this->b = getBlue( color ); -} - -void -Message::render( SDL_Surface* screen, int &x, int &y, Font* font, int time ) { - if( time > 0 ) { - - // default parameters for showing a message - - int dx = font->getHeight(); - int alpha = 255; - - // fading in a message - if( time < 500 ) { - dx = (int)( ( dx * time ) / 600.0 ); - alpha = (int)( ( alpha * time ) / 600.0 ); - } - - // fading out a message - if( time > displayTime - 500 ) { - int timeleft = displayTime - time; - dx = (int)( ( dx * timeleft ) / 600.0 ); - alpha = (int)( ( alpha * timeleft ) / 600.0 ); - } - - // do we still show ourselves? - if( time > displayTime ) { - - dx = 0; - alpha = 0; - - } else { - - font->render( screen, x, y - dx, message.c_str(), r, g, b, alpha ); - - } - - y -= dx; - } -} - -Uint32 -Message::getDisplayTime() { - return displayTime; -} - -Messages::Messages() { - font = new Font( "font.ttf", 12 ); -} - -Messages::~Messages() { - clear(); -} - -void -Messages::addMessage( Uint32 time, Message m ) { - insert( pair< Uint32, Message>( time, m ) ); -} - -void -Messages::cleanup() { - while( ( size() > 0 ) && ( begin()->first + begin()->second.getDisplayTime() < timer.getTime() ) ) - erase( begin() ); -} - -void -Messages::render( SDL_Surface* screen ) { - cleanup(); - int x = 12; - int y = settings.getGameHeight() - 28; - for( reverse_iterator i = rbegin(); i != rend(); i++ ) { - i->second.render( screen, x, y, font, (int)timer.getTime() - (int)i->first ); - } -} - -void -MSGwon(Universe* universe, int nextPlanets, int nextComputerPlayers){ - universe->messages->addMessage( timer.getTime() + 200, Message( "You have QONKuered the solar system! You won!", 20000, 0xffffff ) ); - stringstream s; - s << "Try again, with " << nextPlanets << " planets and " << nextComputerPlayers << " AI players!"; - universe->messages->addMessage( timer.getTime() + 400, Message( s.str(), 20000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 600, Message( "Press [N] ...", 40000, 0x808080 ) ); -} - -void -MSGlost(Universe* universe) { - universe->messages->addMessage( timer.getTime(), Message( "GAME OVER!!! You lost all your planets and ships, you are dead!", 20000, 0xffffff ) ); - universe->messages->addMessage( timer.getTime() + 200, Message( "Press [R] ...", 40000, 0x808080 ) ); -} - -void -MSGstart(Universe* universe) { - universe->messages->addMessage( timer.getTime() + 000, Message( "Let's QONK! Kick the AI players out!", 15000, 0xffffff ) ); - universe->messages->addMessage( timer.getTime() + 200, Message( "[Left click and drag] for multi select, [Middle click] for single select.", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 400, Message( "[Right click] to send ships.", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 600, Message( "[P]ause,[A]ll planets,[R]estart.", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 700, Message( "[Escape] to quit", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 800, Message( "[1]-[0] fleet selection (10%-100%)", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 1000, Message( "Initial fleet selection is 50%", 10000, 0x808080 ) ); -} Deleted: branches/autoconf-2007-03-26-thebohemian/messages.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/messages.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/messages.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,46 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef MESSAGES_H -#define MESSAGES_H - -#include "fonts.h" -#include "extensions.h" -#include "config.h" -#include "universe.h" -#include <SDL/SDL.h> -#include <map> -#include <string> -using namespace std; - -class Universe; - -class Message { -private: - Uint8 r, g, b; - Uint32 displayTime; - string message; -public: - Message( string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ); - Message( string message, Uint32 displayTime, Uint32 color ); - Message( string message, Uint8 r, Uint8 g, Uint8 b ); - Message( string message, Uint32 color ); - void render( SDL_Surface* screen, int &x, int &y, Font* f, int time ); - Uint32 getDisplayTime(); -}; - -class Messages : multimap< Uint32, Message > { -private: - Font* font; -public: - Messages(); - ~Messages(); - void addMessage( Uint32 time, Message m ); - void cleanup(); - void render( SDL_Surface* screen ); - Font* getFont() { return font; } -}; - -void MSGwon(Universe*, int, int); -void MSGlost(Universe*); -void MSGstart(Universe*); -#endif Deleted: branches/autoconf-2007-03-26-thebohemian/planets.cpp =================================================================== --- branches/autoconf-2007-03-26-thebohemian/planets.cpp 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/planets.cpp 2007-04-01 15:00:42 UTC (rev 13) @@ -1,462 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "planets.h" - -#include <SDL_gfxPrimitives.h> - -#include <iostream> -#include <math.h> - -// ##### PLANET ##### - -Planet::Planet() { - rotationSpeed = ( ( rand() % 2 ) * 2 - 1 ) * ( rand() % 60000 + 20000 ); - rotationDistance = 0.05 + 0.4 * ( double )rand() / RAND_MAX; - rotationOffset = rand() % 10000000; - size = 4 + rand() % 4; // [4 ... 8) - isAMoon = false; - mother = NULL; - selected = false; - sourceSelected = false; - owner = NULL; - shipCreationSpeed = 12500 - size*1000; -} - -void -Planet::makeMoon( Planet* mother ) { - rotationSpeed = ( ( rand() % 2 ) * 2 - 1 ) * ( rand() % 2000 + 2000 ); - rotationDistance = 0.01 + 0.03 * ( double )rand() / RAND_MAX; - rotationOffset = rand() % 100000; - size = 2 + rand() % 2; // [2 ... 4) - isAMoon = true; - this->mother = mother; - shipCreationSpeed = 15000 - size*1000; -} - -Coordinate -Planet::getVector( Uint32 time ) const { - double angle = (double)( rotationOffset + time ) / rotationSpeed; - return Coordinate( cos( angle ), sin( angle ) ); -} - -Coordinate -Planet::getLocation( Uint32 time ) const { - Coordinate motherLocation; - if( isAMoon ) { - motherLocation = mother->getLocation(); - } else { - motherLocation.setX( 0.5 ); - motherLocation.setY( 0.5 ); - } - Coordinate v = getVector( time ); - double x = motherLocation.getX() + rotationDistance * v.getX(); - double y = motherLocation.getY() + rotationDistance * v.getY(); - return Coordinate( x, y ); -} - -Coordinate -Planet::getLocation() const { - return getLocation( timer.getTime() ); -} - -void -Planet::addResident( Ship* ship, Uint32 time ) { - if( ( owner == NULL ) || ( owner == ship->getOwner() ) || ( residentShips.size() == 0 ) ) { - if( owner != ship->getOwner() ) { - - // clear out "create ship" actions scheduled for this planet - vector< ActionQueue::iterator > removes; - for( ActionQueue::iterator i = universe->actionQueue->begin(); i != universe->actionQueue->end(); i++ ) { - if( (i->second)->getActionID() == 1 ) { - Planet* planetOfIterator = ((CreateShipAction*)(i->second))->getPlanet(); - if( planetOfIterator == this ) - removes.push_back( i ); - } - } - - for( vector< ActionQueue::iterator >::iterator i = removes.begin(); i != removes.end(); i++ ) { - universe->actionQueue->erase( *i ); - } - - // create a new "create ship" action - buildStartTime = time; - buildEndTime = time + shipCreationSpeed; - universe->actionQueue->scheduleAction( buildEndTime, new CreateShipAction( ship->getOwner(), this ) ); - - // show an animation of planet conquests that are of our interest - Uint32 color = 0; - color = ship->getOwner()->getColor(); - if( owner != NULL ) - if( isAMoon ) - universe->animationQueue->scheduleAction( time + 1200, new SonarAnimation( this, color, 50, time, time + 1000, true ) ); - else - universe->animationQueue->scheduleAction( time + 1200, new SonarAnimation( this, color, 100, time, time + 1000, true ) ); - - } - residentShips.push_back( ship ); - setOwner(ship->getOwner()); - - } else { - ship->die(); - Ship* resident = *( residentShips.begin() ); - removeResident( resident ); - resident->die(); - - // show an animation of die'ing ships that are of our interest - if( ( ship->getOwner()->getPlayerType() == Player::HUMAN ) || ( owner->getPlayerType() == Player::HUMAN ) ) { - universe->animationQueue->scheduleAction( time + 1000, new SonarAnimation( this, ship->getOwner()->getColor(), 20, time, time + 1000, true ) ); - } -// if( owner->getPlayerType() == Player::HUMAN ) { -// universe->animationQueue->scheduleAction( time + 1000, new SonarAnimation( this, 0xc00000, 20, time, time + 1000 ) ); -// } - } -} - -void -Planet::setOwner(Player *newOwner) -{ - if (owner != NULL) - owner->removePlanet(this); - - owner = newOwner; - - newOwner->addPlanet(this); -} - -void -Planet::removeResident( Ship* ship ) { - residentShips.remove( ship ); -} - -void -Planet::render( SDL_Surface* screen ) const { - if( owner->getPlayerType() == Player::HUMAN ) - renderBuildProgress( screen ); - Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawPlanet( screen, x, y, size, owner->getColor() ); - if( selected ) - renderSelector( screen ); - - if( sourceSelected ) - renderSourceSelector( screen ); -} - -void -Planet::renderOrbit( SDL_Surface* screen ) const { - Coordinate centerLocation; - if( isAMoon ) { - centerLocation = mother->getLocation(); - } else { - centerLocation.setX( 0.5 ); - centerLocation.setY( 0.5 ); - } - if( owner != NULL ) - aaellipseRGBA( screen, centerLocation.getXMapped(), centerLocation.getYMapped(), (int)( rotationDistance * settings.getGameWidth() ), (int)( rotationDistance * settings.getGameHeight() ), getRed( owner->getColor() ), getGreen( owner->getColor() ), getBlue( owner->getColor() ), 64 ); - if( getMoon() ) { - mother->renderOrbit( screen ); - } -} - -void -Planet::renderSelector( SDL_Surface* screen ) const { - Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawSelector( screen, x - 4, y - 4, 10, 10, 0, 0, 0 ); - drawSelector( screen, x - 5, y - 5, 10, 10, 255, 192, 0 ); -} - -void -Planet::renderSourceSelector( SDL_Surface* screen ) const { - Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawSelector( screen, x - 4, y - 4, 10, 10, 0, 0, 0 ); - drawSelector( screen, x - 5, y - 5, 10, 10, 255, 255, 255 ); -} - -void -Planet::renderBuildProgress( SDL_Surface* screen ) const { - - - Coordinate location = getLocation(); - Font* font = universe->messages->getFont(); - int x = location.getXMapped(); - int y = location.getYMapped(); - double percentage = 100.0 * ( timer.getTime() - buildStartTime ) / ( buildEndTime - buildStartTime ); - aacircleRGBA( screen, x, y, (int)( size + 102.5 - percentage ), 0xff, 0xff, 0xff, (int)( 0.2 * percentage ) ); - -} - -void -Planet::updateShipLocations() { - if( residentShips.size() > 0 ) { - Coordinate location = getLocation(); - int counter = 0; - double offset = 500 * rotationDistance + (double)timer.getTime() / 10000; - for( list< Ship* >::iterator i = residentShips.begin(); i != residentShips.end(); i++ ) { - double shipX = location.getX() + 0.02 * cos( offset + counter * 2 * PI / residentShips.size() ); - double shipY = location.getY() + 0.02 * sin( offset + counter * 2 * PI / residentShips.size() ); - (*i)->setLocation( shipX, shipY ); - counter++; - } - } -} - -double -Planet::distance( Planet* planet ) { - return planet->getLocation().distance( getLocation() ); -} - -void -Planet::setSourceSelected( bool selected ) { - this->sourceSelected = selected; -} - -void -Planet::setSelected( bool selected ) { - this->selected = selected; -} - -void -Planet::setUniverse( Universe* universe ) { - this->universe = universe; -} - -void -Planet::createShip( const Uint32& time, Player* player ) { - if( player->getPlayerType() != Player::NEUTRAL ) - if( owner == player ) { - player->addShips( this, 1 ); - buildStartTime = time; - buildEndTime = time + shipCreationSpeed; - universe->actionQueue->scheduleAction( buildEndTime, new CreateShipAction( player, this ) ); - } -} - -void -Planet::moveResidentsTo(Planet *destination, int fleetSelection) { - // Save same fuel ... :) - if (destination == this || !residentShips.size()) { - return; - } - - int decampeeCount = (fleetSelection * residentShips.size()) / 100; - if (!decampeeCount) - return; - - // Calling Ship->moveTo will affect the residentShips list so we have to - // copy the ships which are going for war into their own list. - list <Ship *> decampees; - for (list <Ship *>::iterator i = residentShips.begin(); decampeeCount > 0; i++) { - decampees.push_back(*i); - decampeeCount--; - } - - for (list <Ship *>::iterator i = decampees.begin(); i != decampees.end(); i++) { - (*i)->moveTo(timer.getTime() + rand() % 500, destination, universe->actionQueue); - } -} - -// ##### PLANETS ##### - -Planets::Planets() { -} - -Planets::Planets( int numberOfPlanets, int numberOfMoons ) { - - addPlanets( numberOfPlanets ); - addMoons( numberOfMoons ); - -} - -void -Planets::addPlanets( int numberOfPlanets ) { - - for( int i = 0; i < numberOfPlanets; i++ ) { - push_back( Planet() ); - } - -} - -void -Planets::addMoons( int numberOfMoons ) { - - if( size() == 0 ) { - cerr << "Error constructing moons, no planets yet" << endl; - exit( 1 ); - } - - for( int i = 0; i < numberOfMoons; i++ ) { - iterator motherPlanet; - bool done = false; - do { - int mother = rand() % size(); - motherPlanet = begin(); - for( int j = 0; j < mother; j++ ) motherPlanet++; - done = !motherPlanet->getMoon(); - } while( !done ); - Planet p; - p.makeMoon( &(*motherPlanet) ); - push_back( p ); - } - -} - -void -Planets::render( SDL_Surface* screen ) const { - for( const_iterator i = begin(); i != end(); i++ ) - i->render( screen ); -} - -void -Planets::renderOrbits( SDL_Surface* screen ) const { - for( const_iterator i = begin(); i != end(); i++ ) - i->renderOrbit( screen ); -} - -Planet* -Planets::closestToCoordinate( const Coordinate& c ) { - double closestDistance = 5000; - Planet* closestPlanet = NULL; - for( iterator i = begin(); i != end(); i++ ) { - double distance = i->getLocation().distance( c ); - if( distance < closestDistance ) { - closestDistance = distance; - closestPlanet = &(*i); - } - } - return closestPlanet; -} - -Planet* -Planets::closestToCoordinate( const Coordinate& c, double treshold ) { - Planet* closest = closestToCoordinate( c ); - if( closest->getLocation().distance( c ) < treshold ) - return closest; - else - return NULL; -} - -void -Planets::select( Selection selection ) { - - double minX = selection.getMinX(); - double maxX = selection.getMaxX(); - double minY = selection.getMinY(); - double maxY = selection.getMaxY(); - - for( iterator i = begin(); i != end(); i++ ) { - Coordinate location = i->getLocation(); - if( ( location.getX() > minX ) && ( location.getX() < maxX ) && ( location.getY() > minY ) && ( location.getY() < maxY ) ) - i->setSelected( true ); - else - i->setSelected( false ); - } - -} - -void -Planets::sourceSelect( Selection *selection, Player *owner ) { - - double minX = selection->getMinX(); - double maxX = selection->getMaxX(); - double minY = selection->getMinY(); - double maxY = selection->getMaxY(); - - for( iterator i = begin(); i != end(); i++ ) { - Coordinate location = i->getLocation(); - if( ( location.getX() > minX ) && ( location.getX() < maxX ) - && ( location.getY() > minY ) && ( location.getY() < maxY ) - && i->getOwner() == owner ) - i->setSourceSelected( true ); - else - i->setSourceSelected( false ); - } - -} - -void -Planets::updateShipLocations() { - for( iterator i = begin(); i != end(); i++ ) - i->updateShipLocations(); -} - -void -Planets::setUniverse( Universe* universe ) { - for( iterator i = begin(); i != end(); i++ ) - i->setUniverse( universe ); -} - -Planet* -Planets::getRandomPlanet() { - int number = rand() % size(); - iterator i = begin(); - for( int k = 0; k < number; k++ ) - i++; - return &(*i); -} - -Planet* -Planets::getRandomEnemyPlanet( Player* player ) { -} - -Planet* -Planets::getRandomNearbyPlanet( Planet* planet ) { - - Planet* result; - do { - result = getRandomPlanet(); - } while( result == planet ); - double distance = planet->distance( result ); - - for( int i = 0; i < size() / 2; i++ ) { - Planet* otherPlanet; - do { - otherPlanet = getRandomPlanet(); - } while( otherPlanet == planet ); - double otherDistance = planet->distance( otherPlanet ); - - // which planets do we prefer? - - if( otherPlanet->getOwner() != planet->getOwner() ) - otherDistance *= 0.1; - if( otherPlanet->getOwner()->getPlayerType() == Player::NEUTRAL ) - otherDistance *= 0.5; - if( ! otherPlanet->getMoon() ) - otherDistance *= 0.8; - - if( otherDistance < distance ) { - result = otherPlanet; - distance = otherDistance; - } - } - - return result; - -} - -// ##### CREATESHIPACTION ##### - -CreateShipAction::CreateShipAction() : -Action::Action() { - actionID = 1; -} - -CreateShipAction::CreateShipAction( Player* player, Planet* planet ) { - this->player = player; - this->planet = planet; - actionID = 1; -} - -void -CreateShipAction::execute( const Uint32& time ) { - planet->createShip( time, player ); -} - -Planet* -CreateShipAction::getPlanet() const { - return planet; -} Deleted: branches/autoconf-2007-03-26-thebohemian/planets.h =================================================================== --- branches/autoconf-2007-03-26-thebohemian/planets.h 2007-03-26 15:01:02 UTC (rev 12) +++ branches/autoconf-2007-03-26-thebohemian/planets.h 2007-04-01 15:00:42 UTC (rev 13) @@ -1,110 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef PLANETS_H -#define PLANETS_H - -#include "coordinate.h" -#include "ships.h" -#include "extensions.h" -#include "selection.h" -#include "actions.h" -#include "config.h" -#include <SDL/SDL.h> -#include <sstream> -#include <list> -using namespace std; - -class Ship; -class Ships; -class Player; -class Players; -class Universe; - -class Planet { -private: - Universe* universe; - Player* owner; - int rotationSpeed, rotationOffset; - double rotationDistance; - int shipCreationSpeed; - int size; - bool isAMoon, selected, sourceSelected; ... [truncated message content] |
From: <eX...@us...> - 2007-03-26 15:05:18
|
Revision: 12 http://qonk.svn.sourceforge.net/qonk/?rev=12&view=rev Author: eXinion Date: 2007-03-26 08:01:02 -0700 (Mon, 26 Mar 2007) Log Message: ----------- Modified Paths: -------------- branches/networked_original_2007-03-26/server/main.cpp Modified: branches/networked_original_2007-03-26/server/main.cpp =================================================================== --- branches/networked_original_2007-03-26/server/main.cpp 2007-03-26 14:59:47 UTC (rev 11) +++ branches/networked_original_2007-03-26/server/main.cpp 2007-03-26 15:01:02 UTC (rev 12) @@ -44,12 +44,11 @@ state = STARTUP; int numberOfPlayers = 2; - int numberOfPlanets = 4; if (argc >= 2) { numberOfPlayers = atoi(argv[1]); - numberOfPlanets = numberOfPlayers*2; } + numberOfPlanets = numberOfPlayers*2; if (argc >= 3) { numberOfPlanets = atoi(argv[2]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eX...@us...> - 2007-03-26 15:05:17
|
Revision: 10 http://qonk.svn.sourceforge.net/qonk/?rev=10&view=rev Author: eXinion Date: 2007-03-26 07:55:05 -0700 (Mon, 26 Mar 2007) Log Message: ----------- Added Paths: ----------- branches/networked_original_2007-03-26/ branches/networked_original_2007-03-26/client/ branches/networked_original_2007-03-26/client/COPYING branches/networked_original_2007-03-26/client/Makefile branches/networked_original_2007-03-26/client/Makefile_client branches/networked_original_2007-03-26/client/SDL_gfxPrimitives.c branches/networked_original_2007-03-26/client/SDL_gfxPrimitives.h branches/networked_original_2007-03-26/client/SDL_gfxPrimitives_font.h branches/networked_original_2007-03-26/client/actions.cpp branches/networked_original_2007-03-26/client/actions.h branches/networked_original_2007-03-26/client/animations.cpp branches/networked_original_2007-03-26/client/animations.h branches/networked_original_2007-03-26/client/config.cpp branches/networked_original_2007-03-26/client/config.h branches/networked_original_2007-03-26/client/coordinate.cpp branches/networked_original_2007-03-26/client/coordinate.h branches/networked_original_2007-03-26/client/extensions.cpp branches/networked_original_2007-03-26/client/extensions.h branches/networked_original_2007-03-26/client/font.ttf branches/networked_original_2007-03-26/client/fonts.cpp branches/networked_original_2007-03-26/client/fonts.h branches/networked_original_2007-03-26/client/gmon.out branches/networked_original_2007-03-26/client/main.cpp branches/networked_original_2007-03-26/client/messages.cpp branches/networked_original_2007-03-26/client/messages.h branches/networked_original_2007-03-26/client/network.cpp branches/networked_original_2007-03-26/client/network.h branches/networked_original_2007-03-26/client/output branches/networked_original_2007-03-26/client/planets.cpp branches/networked_original_2007-03-26/client/planets.h branches/networked_original_2007-03-26/client/players.cpp branches/networked_original_2007-03-26/client/players.h branches/networked_original_2007-03-26/client/profile branches/networked_original_2007-03-26/client/raknet/ branches/networked_original_2007-03-26/client/raknet/NetworkTypes.h branches/networked_original_2007-03-26/client/raknet/PacketEnumerations.h branches/networked_original_2007-03-26/client/raknet/PacketPriority.h branches/networked_original_2007-03-26/client/raknet/RakClientInterface.h branches/networked_original_2007-03-26/client/raknet/RakNetLibStatic.lib branches/networked_original_2007-03-26/client/raknet/RakNetLibStaticDebug.lib branches/networked_original_2007-03-26/client/raknet/RakNetworkFactory.h branches/networked_original_2007-03-26/client/raknet/RakPeerInterface.h branches/networked_original_2007-03-26/client/raknet/RakServerInterface.h branches/networked_original_2007-03-26/client/raknet/network.cpp branches/networked_original_2007-03-26/client/raknet/network.h branches/networked_original_2007-03-26/client/raknet/ships.cpp branches/networked_original_2007-03-26/client/raknet/ships.h branches/networked_original_2007-03-26/client/selection.cpp branches/networked_original_2007-03-26/client/selection.h branches/networked_original_2007-03-26/client/ships.cpp branches/networked_original_2007-03-26/client/ships.h branches/networked_original_2007-03-26/client/stars.cpp branches/networked_original_2007-03-26/client/stars.h branches/networked_original_2007-03-26/client/timer.cpp branches/networked_original_2007-03-26/client/timer.h branches/networked_original_2007-03-26/client/universe.cpp branches/networked_original_2007-03-26/client/universe.h branches/networked_original_2007-03-26/server/ branches/networked_original_2007-03-26/server/COPYING branches/networked_original_2007-03-26/server/Makefile branches/networked_original_2007-03-26/server/SDL_gfxPrimitives.c branches/networked_original_2007-03-26/server/SDL_gfxPrimitives.h branches/networked_original_2007-03-26/server/SDL_gfxPrimitives_font.h branches/networked_original_2007-03-26/server/actions.cpp branches/networked_original_2007-03-26/server/actions.h branches/networked_original_2007-03-26/server/animations.cpp branches/networked_original_2007-03-26/server/animations.h branches/networked_original_2007-03-26/server/config.cpp branches/networked_original_2007-03-26/server/config.h branches/networked_original_2007-03-26/server/coordinate.cpp branches/networked_original_2007-03-26/server/coordinate.h branches/networked_original_2007-03-26/server/extensions.cpp branches/networked_original_2007-03-26/server/extensions.h branches/networked_original_2007-03-26/server/font.ttf branches/networked_original_2007-03-26/server/fonts.cpp branches/networked_original_2007-03-26/server/fonts.h branches/networked_original_2007-03-26/server/gmon.out branches/networked_original_2007-03-26/server/main.cpp branches/networked_original_2007-03-26/server/main.cpp.notneeded branches/networked_original_2007-03-26/server/main.h branches/networked_original_2007-03-26/server/messages.cpp branches/networked_original_2007-03-26/server/messages.h branches/networked_original_2007-03-26/server/network.cpp branches/networked_original_2007-03-26/server/network.h branches/networked_original_2007-03-26/server/output branches/networked_original_2007-03-26/server/planets.cpp branches/networked_original_2007-03-26/server/planets.h branches/networked_original_2007-03-26/server/players.cpp branches/networked_original_2007-03-26/server/players.h branches/networked_original_2007-03-26/server/profile branches/networked_original_2007-03-26/server/raknet/ branches/networked_original_2007-03-26/server/raknet/NetworkTypes.h branches/networked_original_2007-03-26/server/raknet/PacketEnumerations.h branches/networked_original_2007-03-26/server/raknet/PacketPriority.h branches/networked_original_2007-03-26/server/raknet/RakClientInterface.h branches/networked_original_2007-03-26/server/raknet/RakNetLibStatic.lib branches/networked_original_2007-03-26/server/raknet/RakNetLibStaticDebug.lib branches/networked_original_2007-03-26/server/raknet/RakNetworkFactory.h branches/networked_original_2007-03-26/server/raknet/RakPeerInterface.h branches/networked_original_2007-03-26/server/raknet/RakServerInterface.h branches/networked_original_2007-03-26/server/selection.cpp branches/networked_original_2007-03-26/server/selection.h branches/networked_original_2007-03-26/server/ships.cpp branches/networked_original_2007-03-26/server/ships.h branches/networked_original_2007-03-26/server/stars.cpp branches/networked_original_2007-03-26/server/stars.h branches/networked_original_2007-03-26/server/timer.cpp branches/networked_original_2007-03-26/server/timer.h branches/networked_original_2007-03-26/server/universe.cpp branches/networked_original_2007-03-26/server/universe.h Added: branches/networked_original_2007-03-26/client/COPYING =================================================================== --- branches/networked_original_2007-03-26/client/COPYING (rev 0) +++ branches/networked_original_2007-03-26/client/COPYING 2007-03-26 14:55:05 UTC (rev 10) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Added: branches/networked_original_2007-03-26/client/Makefile =================================================================== --- branches/networked_original_2007-03-26/client/Makefile (rev 0) +++ branches/networked_original_2007-03-26/client/Makefile 2007-03-26 14:55:05 UTC (rev 10) @@ -0,0 +1,15 @@ +CXX=g++ +CFLAGS=`sdl-config --cflags` -O3 -I/usr/local/include/raknet +LIBS=`sdl-config --libs` -lSDL_ttf -lraknet +OBJECTS=SDL_gfxPrimitives.o extensions.o coordinate.o stars.o planets.o selection.o ships.o main.o actions.o players.o universe.o animations.o fonts.o messages.o timer.o config.o network.o + +all: qonk + +qonk: $(OBJECTS) + $(CXX) $(CFLAGS) $(LIBS) $(OBJECTS) -o qonk + +.cpp.o: + $(CXX) $(CFLAGS) -c $< + +clean: + @rm -vf *.o *~ qonk screenshot.bmp DEADJOE Added: branches/networked_original_2007-03-26/client/Makefile_client =================================================================== --- branches/networked_original_2007-03-26/client/Makefile_client (rev 0) +++ branches/networked_original_2007-03-26/client/Makefile_client 2007-03-26 14:55:05 UTC (rev 10) @@ -0,0 +1,15 @@ +CXX=g++ +CFLAGS=`sdl-config --cflags` -O3 -I/usr/local/include/raknet -I/usr/local/lib +LIBS=`sdl-config --libs` -lSDL_ttf -lraknet +OBJECTS=SDL_gfxPrimitives.o extensions.o coordinate.o stars.o planets.o selection.o ships.o main.o actions.o players.o universe.o animations.o fonts.o messages.o timer.o config.o network.o + +all: qonk + +qonk: $(OBJECTS) + $(CXX) $(CFLAGS) $(LIBS) $(OBJECTS) -o qonk + +.cpp.o: + $(CXX) $(CFLAGS) -c $< + +clean: + @rm -vf *.o *~ qonk screenshot.bmp DEADJOE Added: branches/networked_original_2007-03-26/client/SDL_gfxPrimitives.c =================================================================== --- branches/networked_original_2007-03-26/client/SDL_gfxPrimitives.c (rev 0) +++ branches/networked_original_2007-03-26/client/SDL_gfxPrimitives.c 2007-03-26 14:55:05 UTC (rev 10) @@ -0,0 +1,3708 @@ +/* + + SDL_gfxPrimitives - Graphics primitives for SDL surfaces + + LGPL (c) A. Schiffler + +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +#include "SDL_gfxPrimitives.h" +#include "SDL_gfxPrimitives_font.h" + +/* -===================- */ + +/* ----- Defines for pixel clipping tests */ + +#define clip_xmin(surface) surface->clip_rect.x +#define clip_xmax(surface) surface->clip_rect.x+surface->clip_rect.w-1 +#define clip_ymin(surface) surface->clip_rect.y +#define clip_ymax(surface) surface->clip_rect.y+surface->clip_rect.h-1 + +/* ----- Pixel - fast, no blending, no locking, clipping */ + +int fastPixelColorNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + int bpp; + Uint8 *p; + + /* + * Honor clipping setup at pixel level + */ + if ((x >= clip_xmin(dst)) && (x <= clip_xmax(dst)) && (y >= clip_ymin(dst)) && (y <= clip_ymax(dst))) { + + /* + * Get destination format + */ + bpp = dst->format->BytesPerPixel; + p = (Uint8 *) dst->pixels + y * dst->pitch + x * bpp; + switch (bpp) { + case 1: + *p = color; + break; + case 2: + *(Uint16 *) p = color; + break; + case 3: + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + p[0] = (color >> 16) & 0xff; + p[1] = (color >> 8) & 0xff; + p[2] = color & 0xff; + } else { + p[0] = color & 0xff; + p[1] = (color >> 8) & 0xff; + p[2] = (color >> 16) & 0xff; + } + break; + case 4: + *(Uint32 *) p = color; + break; + } /* switch */ + + + } + + return (0); +} + +/* ----- Pixel - fast, no blending, no locking, no clipping */ + +/* (faster but dangerous, make sure we stay in surface bounds) */ + +int fastPixelColorNolockNoclip(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + int bpp; + Uint8 *p; + + /* + * Get destination format + */ + bpp = dst->format->BytesPerPixel; + p = (Uint8 *) dst->pixels + y * dst->pitch + x * bpp; + switch (bpp) { + case 1: + *p = color; + break; + case 2: + *(Uint16 *) p = color; + break; + case 3: + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + p[0] = (color >> 16) & 0xff; + p[1] = (color >> 8) & 0xff; + p[2] = color & 0xff; + } else { + p[0] = color & 0xff; + p[1] = (color >> 8) & 0xff; + p[2] = (color >> 16) & 0xff; + } + break; + case 4: + *(Uint32 *) p = color; + break; + } /* switch */ + + return (0); +} + +/* ----- Pixel - fast, no blending, locking, clipping */ + +int fastPixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + int result; + + /* + * Lock the surface + */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + result = fastPixelColorNolock(dst, x, y, color); + + /* + * Unlock surface + */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +/* ----- Pixel - fast, no blending, locking, RGB input */ + +int fastPixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color; + + /* + * Setup color + */ + color = SDL_MapRGBA(dst->format, r, g, b, a); + + /* + * Draw + */ + return (fastPixelColor(dst, x, y, color)); + +} + +/* ----- Pixel - fast, no blending, no locking RGB input */ + +int fastPixelRGBANolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color; + + /* + * Setup color + */ + color = SDL_MapRGBA(dst->format, r, g, b, a); + + /* + * Draw + */ + return (fastPixelColorNolock(dst, x, y, color)); +} + +/* PutPixel routine with alpha blending, input color in destination format */ + +/* New, faster routine - default blending pixel */ + +int _putPixelAlpha(SDL_Surface * surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha) +{ + Uint32 Rmask = surface->format->Rmask, Gmask = + surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask; + Uint32 R, G, B, A = 0; + + if (x >= clip_xmin(surface) && x <= clip_xmax(surface) + && y >= clip_ymin(surface) && y <= clip_ymax(surface)) { + + switch (surface->format->BytesPerPixel) { + case 1:{ /* Assuming 8-bpp */ + if (alpha == 255) { + *((Uint8 *) surface->pixels + y * surface->pitch + x) = color; + } else { + Uint8 *pixel = (Uint8 *) surface->pixels + y * surface->pitch + x; + + Uint8 dR = surface->format->palette->colors[*pixel].r; + Uint8 dG = surface->format->palette->colors[*pixel].g; + Uint8 dB = surface->format->palette->colors[*pixel].b; + Uint8 sR = surface->format->palette->colors[color].r; + Uint8 sG = surface->format->palette->colors[color].g; + Uint8 sB = surface->format->palette->colors[color].b; + + dR = dR + ((sR - dR) * alpha >> 8); + dG = dG + ((sG - dG) * alpha >> 8); + dB = dB + ((sB - dB) * alpha >> 8); + + *pixel = SDL_MapRGB(surface->format, dR, dG, dB); + } + } + break; + + case 2:{ /* Probably 15-bpp or 16-bpp */ + if (alpha == 255) { + *((Uint16 *) surface->pixels + y * surface->pitch / 2 + x) = color; + } else { + Uint16 *pixel = (Uint16 *) surface->pixels + y * surface->pitch / 2 + x; + Uint32 dc = *pixel; + + R = ((dc & Rmask) + (((color & Rmask) - (dc & Rmask)) * alpha >> 8)) & Rmask; + G = ((dc & Gmask) + (((color & Gmask) - (dc & Gmask)) * alpha >> 8)) & Gmask; + B = ((dc & Bmask) + (((color & Bmask) - (dc & Bmask)) * alpha >> 8)) & Bmask; + if (Amask) + A = ((dc & Amask) + (((color & Amask) - (dc & Amask)) * alpha >> 8)) & Amask; + + *pixel = R | G | B | A; + } + } + break; + + case 3:{ /* Slow 24-bpp mode, usually not used */ + Uint8 *pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3; + Uint8 rshift8 = surface->format->Rshift / 8; + Uint8 gshift8 = surface->format->Gshift / 8; + Uint8 bshift8 = surface->format->Bshift / 8; + Uint8 ashift8 = surface->format->Ashift / 8; + + + if (alpha == 255) { + *(pix + rshift8) = color >> surface->format->Rshift; + *(pix + gshift8) = color >> surface->format->Gshift; + *(pix + bshift8) = color >> surface->format->Bshift; + *(pix + ashift8) = color >> surface->format->Ashift; + } else { + Uint8 dR, dG, dB, dA = 0; + Uint8 sR, sG, sB, sA = 0; + + pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3; + + dR = *((pix) + rshift8); + dG = *((pix) + gshift8); + dB = *((pix) + bshift8); + dA = *((pix) + ashift8); + + sR = (color >> surface->format->Rshift) & 0xff; + sG = (color >> surface->format->Gshift) & 0xff; + sB = (color >> surface->format->Bshift) & 0xff; + sA = (color >> surface->format->Ashift) & 0xff; + + dR = dR + ((sR - dR) * alpha >> 8); + dG = dG + ((sG - dG) * alpha >> 8); + dB = dB + ((sB - dB) * alpha >> 8); + dA = dA + ((sA - dA) * alpha >> 8); + + *((pix) + rshift8) = dR; + *((pix) + gshift8) = dG; + *((pix) + bshift8) = dB; + *((pix) + ashift8) = dA; + } + } + break; + + case 4:{ /* Probably 32-bpp */ + if (alpha == 255) { + *((Uint32 *) surface->pixels + y * surface->pitch / 4 + x) = color; + } else { + Uint32 *pixel = (Uint32 *) surface->pixels + y * surface->pitch / 4 + x; + Uint32 dc = *pixel; + + R = ((dc & Rmask) + (((color & Rmask) - (dc & Rmask)) * alpha >> 8)) & Rmask; + G = ((dc & Gmask) + (((color & Gmask) - (dc & Gmask)) * alpha >> 8)) & Gmask; + B = ((dc & Bmask) + (((color & Bmask) - (dc & Bmask)) * alpha >> 8)) & Bmask; + if (Amask) + A = ((dc & Amask) + (((color & Amask) - (dc & Amask)) * alpha >> 8)) & Amask; + + *pixel = R | G | B | A; + } + } + break; + } + } + + return (0); +} + +/* ----- Pixel - pixel draw with blending enabled if a<255 */ + +int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + Uint8 alpha; + Uint32 mcolor; + int result = 0; + + /* + * Lock the surface + */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* + * Setup color + */ + alpha = color & 0x000000ff; + mcolor = + SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24, + (color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha); + + /* + * Draw + */ + result = _putPixelAlpha(dst, x, y, mcolor, alpha); + + /* + * Unlock the surface + */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +int pixelColorNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + Uint8 alpha; + Uint32 mcolor; + int result = 0; + + /* + * Setup color + */ + alpha = color & 0x000000ff; + mcolor = + SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24, + (color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha); + + /* + * Draw + */ + result = _putPixelAlpha(dst, x, y, mcolor, alpha); + + return (result); +} + + +/* Filled rectangle with alpha blending, color in destination format */ + +int _filledRectAlpha(SDL_Surface * surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color, Uint8 alpha) +{ + Uint32 Rmask = surface->format->Rmask, Gmask = + surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask; + Uint32 R, G, B, A = 0; + Sint16 x, y; + + switch (surface->format->BytesPerPixel) { + case 1:{ /* Assuming 8-bpp */ + Uint8 *row, *pixel; + Uint8 dR, dG, dB; + + Uint8 sR = surface->format->palette->colors[color].r; + Uint8 sG = surface->format->palette->colors[color].g; + Uint8 sB = surface->format->palette->colors[color].b; + + for (y = y1; y <= y2; y++) { + row = (Uint8 *) surface->pixels + y * surface->pitch; + for (x = x1; x <= x2; x++) { + pixel = row + x; + + dR = surface->format->palette->colors[*pixel].r; + dG = surface->format->palette->colors[*pixel].g; + dB = surface->format->palette->colors[*pixel].b; + + dR = dR + ((sR - dR) * alpha >> 8); + dG = dG + ((sG - dG) * alpha >> 8); + dB = dB + ((sB - dB) * alpha >> 8); + + *pixel = SDL_MapRGB(surface->format, dR, dG, dB); + } + } + } + break; + + case 2:{ /* Probably 15-bpp or 16-bpp */ + Uint16 *row, *pixel; + Uint32 dR = (color & Rmask), dG = (color & Gmask), dB = (color & Bmask), dA = (color & Amask); + + for (y = y1; y <= y2; y++) { + row = (Uint16 *) surface->pixels + y * surface->pitch / 2; + for (x = x1; x <= x2; x++) { + pixel = row + x; + + R = ((*pixel & Rmask) + ((dR - (*pixel & Rmask)) * alpha >> 8)) & Rmask; + G = ((*pixel & Gmask) + ((dG - (*pixel & Gmask)) * alpha >> 8)) & Gmask; + B = ((*pixel & Bmask) + ((dB - (*pixel & Bmask)) * alpha >> 8)) & Bmask; + if (Amask) + A = ((*pixel & Amask) + ((dA - (*pixel & Amask)) * alpha >> 8)) & Amask; + + *pixel = R | G | B | A; + } + } + } + break; + + case 3:{ /* Slow 24-bpp mode, usually not used */ + Uint8 *row, *pix; + Uint8 dR, dG, dB, dA; + Uint8 rshift8 = surface->format->Rshift / 8; + Uint8 gshift8 = surface->format->Gshift / 8; + Uint8 bshift8 = surface->format->Bshift / 8; + Uint8 ashift8 = surface->format->Ashift / 8; + + Uint8 sR = (color >> surface->format->Rshift) & 0xff; + Uint8 sG = (color >> surface->format->Gshift) & 0xff; + Uint8 sB = (color >> surface->format->Bshift) & 0xff; + Uint8 sA = (color >> surface->format->Ashift) & 0xff; + + for (y = y1; y <= y2; y++) { + row = (Uint8 *) surface->pixels + y * surface->pitch; + for (x = x1; x <= x2; x++) { + pix = row + x * 3; + + dR = *((pix) + rshift8); + dG = *((pix) + gshift8); + dB = *((pix) + bshift8); + dA = *((pix) + ashift8); + + dR = dR + ((sR - dR) * alpha >> 8); + dG = dG + ((sG - dG) * alpha >> 8); + dB = dB + ((sB - dB) * alpha >> 8); + dA = dA + ((sA - dA) * alpha >> 8); + + *((pix) + rshift8) = dR; + *((pix) + gshift8) = dG; + *((pix) + bshift8) = dB; + *((pix) + ashift8) = dA; + } + } + + } + break; + + case 4:{ /* Probably 32-bpp */ + Uint32 *row, *pixel; + Uint32 dR = (color & Rmask), dG = (color & Gmask), dB = (color & Bmask), dA = (color & Amask); + + for (y = y1; y <= y2; y++) { + row = (Uint32 *) surface->pixels + y * surface->pitch / 4; + for (x = x1; x <= x2; x++) { + pixel = row + x; + + R = ((*pixel & Rmask) + ((dR - (*pixel & Rmask)) * alpha >> 8)) & Rmask; + G = ((*pixel & Gmask) + ((dG - (*pixel & Gmask)) * alpha >> 8)) & Gmask; + B = ((*pixel & Bmask) + ((dB - (*pixel & Bmask)) * alpha >> 8)) & Bmask; + if (Amask) + A = ((*pixel & Amask) + ((dA - (*pixel & Amask)) * alpha >> 8)) & Amask; + + *pixel = R | G | B | A; + } + } + } + break; + } + + return (0); +} + +/* Draw rectangle with alpha enabled from RGBA color. */ + +int filledRectAlpha(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + Uint8 alpha; + Uint32 mcolor; + int result = 0; + + /* + * Lock the surface + */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* + * Setup color + */ + alpha = color & 0x000000ff; + mcolor = + SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24, + (color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha); + + /* + * Draw + */ + result = _filledRectAlpha(dst, x1, y1, x2, y2, mcolor, alpha); + + /* + * Unlock the surface + */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +/* Draw horizontal line with alpha enabled from RGBA color */ + +int HLineAlpha(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) +{ + return (filledRectAlpha(dst, x1, y, x2, y, color)); +} + + +/* Draw vertical line with alpha enabled from RGBA color */ + +int VLineAlpha(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color) +{ + return (filledRectAlpha(dst, x, y1, x, y2, color)); +} + + +/* Pixel - using alpha weight on color for AA-drawing */ + +int pixelColorWeight(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight) +{ + Uint32 a; + + /* + * Get alpha + */ + a = (color & (Uint32) 0x000000ff); + + /* + * Modify Alpha by weight + */ + a = ((a * weight) >> 8); + + return (pixelColor(dst, x, y, (color & (Uint32) 0xffffff00) | (Uint32) a)); +} + +/* Pixel - using alpha weight on color for AA-drawing - no locking */ + +int pixelColorWeightNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight) +{ + Uint32 a; + + /* + * Get alpha + */ + a = (color & (Uint32) 0x000000ff); + + /* + * Modify Alpha by weight + */ + a = ((a * weight) >> 8); + + return (pixelColorNolock(dst, x, y, (color & (Uint32) 0xffffff00) | (Uint32) a)); +} + +int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color; + + /* + * Check Alpha + */ + if (a == 255) { + /* + * No alpha blending required + */ + /* + * Setup color + */ + color = SDL_MapRGBA(dst->format, r, g, b, a); + /* + * Draw + */ + return (fastPixelColor(dst, x, y, color)); + } else { + /* + * Alpha blending required + */ + /* + * Draw + */ + return (pixelColor(dst, x, y, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); + } +} + +/* ----- Horizontal line */ + +/* Just store color including alpha, no blending */ + +int hlineColorStore(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) +{ + Sint16 left, right, top, bottom; + Uint8 *pixel, *pixellast; + int dx; + int pixx, pixy; + Sint16 w; + Sint16 xtmp; + int result = -1; + + /* + * Get clipping boundary + */ + left = dst->clip_rect.x; + right = dst->clip_rect.x + dst->clip_rect.w - 1; + top = dst->clip_rect.y; + bottom = dst->clip_rect.y + dst->clip_rect.h - 1; + + /* + * Check visibility of hline + */ + if ((x1<left) && (x2<left)) { + return(0); + } + if ((x1>right) && (x2>right)) { + return(0); + } + if ((y<top) || (y>bottom)) { + return (0); + } + + /* + * Clip x + */ + if (x1 < left) { + x1 = left; + } + if (x2 > right) { + x2 = right; + } + + /* + * Swap x1, x2 if required + */ + if (x1 > x2) { + xtmp = x1; + x1 = x2; + x2 = xtmp; + } + + /* + * Calculate width + */ + w = x2 - x1; + + /* + * Sanity check on width + */ + if (w < 0) { + return (0); + } + + /* + * Lock surface + */ + SDL_LockSurface(dst); + + /* + * More variable setup + */ + dx = w; + pixx = dst->format->BytesPerPixel; + pixy = dst->pitch; + pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y; + + /* + * Draw + */ + switch (dst->format->BytesPerPixel) { + case 1: + memset(pixel, color, dx); + break; + case 2: + pixellast = pixel + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + *(Uint16 *) pixel = color; + } + break; + case 3: + pixellast = pixel + dx + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + } + break; + default: /* case 4 */ + dx = dx + dx; + pixellast = pixel + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + *(Uint32 *) pixel = color; + } + break; + } + + /* + * Unlock surface + */ + SDL_UnlockSurface(dst); + + /* + * Set result code + */ + result = 0; + + return (result); +} + +int hlineRGBAStore(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (hlineColorStore(dst, x1, x2, y, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) +{ + Sint16 left, right, top, bottom; + Uint8 *pixel, *pixellast; + int dx; + int pixx, pixy; + Sint16 w; + Sint16 xtmp; + int result = -1; + Uint8 *colorptr; + + /* + * Get clipping boundary + */ + left = dst->clip_rect.x; + right = dst->clip_rect.x + dst->clip_rect.w - 1; + top = dst->clip_rect.y; + bottom = dst->clip_rect.y + dst->clip_rect.h - 1; + + /* + * Check visibility of hline + */ + if ((x1<left) && (x2<left)) { + return(0); + } + if ((x1>right) && (x2>right)) { + return(0); + } + if ((y<top) || (y>bottom)) { + return (0); + } + + /* + * Clip x + */ + if (x1 < left) { + x1 = left; + } + if (x2 > right) { + x2 = right; + } + + /* + * Swap x1, x2 if required + */ + if (x1 > x2) { + xtmp = x1; + x1 = x2; + x2 = xtmp; + } + + /* + * Calculate width + */ + w = x2 - x1; + + /* + * Sanity check on width + */ + if (w < 0) { + return (0); + } + + /* + * Alpha check + */ + if ((color & 255) == 255) { + + /* + * No alpha-blending required + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + /* + * Lock surface + */ + SDL_LockSurface(dst); + + /* + * More variable setup + */ + dx = w; + pixx = dst->format->BytesPerPixel; + pixy = dst->pitch; + pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y; + + /* + * Draw + */ + switch (dst->format->BytesPerPixel) { + case 1: + memset(pixel, color, dx); + break; + case 2: + pixellast = pixel + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + *(Uint16 *) pixel = color; + } + break; + case 3: + pixellast = pixel + dx + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + } + break; + default: /* case 4 */ + dx = dx + dx; + pixellast = pixel + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + *(Uint32 *) pixel = color; + } + break; + } + + /* + * Unlock surface + */ + SDL_UnlockSurface(dst); + + /* + * Set result code + */ + result = 0; + + } else { + + /* + * Alpha blending blit + */ + + result = HLineAlpha(dst, x1, x1 + w, y, color); + + } + + return (result); +} + +int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (hlineColor(dst, x1, x2, y, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- Vertical line */ + +int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color) +{ + Sint16 left, right, top, bottom; + Uint8 *pixel, *pixellast; + int dy; + int pixx, pixy; + Sint16 h; + Sint16 ytmp; + int result = -1; + Uint8 *colorptr; + + /* + * Get clipping boundary + */ + left = dst->clip_rect.x; + right = dst->clip_rect.x + dst->clip_rect.w - 1; + top = dst->clip_rect.y; + bottom = dst->clip_rect.y + dst->clip_rect.h - 1; + + /* + * Check visibility of vline + */ + if ((x<left) || (x>right)) { + return (0); + } + if ((y1<top) && (y2<top)) { + return(0); + } + if ((y1>bottom) && (y2>bottom)) { + return(0); + } + + /* + * Clip y + */ + if (y1 < top) { + y1 = top; + } + if (y2 > bottom) { + y2 = bottom; + } + + /* + * Swap y1, y2 if required + */ + if (y1 > y2) { + ytmp = y1; + y1 = y2; + y2 = ytmp; + } + + /* + * Calculate height + */ + h = y2 - y1; + + /* + * Sanity check on height + */ + if (h < 0) { + return (0); + } + + /* + * Alpha check + */ + if ((color & 255) == 255) { + + /* + * No alpha-blending required + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + /* + * Lock surface + */ + SDL_LockSurface(dst); + + /* + * More variable setup + */ + dy = h; + pixx = dst->format->BytesPerPixel; + pixy = dst->pitch; + pixel = ((Uint8 *) dst->pixels) + pixx * (int) x + pixy * (int) y1; + pixellast = pixel + pixy * dy; + + /* + * Draw + */ + switch (dst->format->BytesPerPixel) { + case 1: + for (; pixel <= pixellast; pixel += pixy) { + *(Uint8 *) pixel = color; + } + break; + case 2: + for (; pixel <= pixellast; pixel += pixy) { + *(Uint16 *) pixel = color; + } + break; + case 3: + for (; pixel <= pixellast; pixel += pixy) { + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + } + break; + default: /* case 4 */ + for (; pixel <= pixellast; pixel += pixy) { + *(Uint32 *) pixel = color; + } + break; + } + + /* + * Unlock surface + */ + SDL_UnlockSurface(dst); + + /* + * Set result code + */ + result = 0; + + } else { + + /* + * Alpha blending blit + */ + + result = VLineAlpha(dst, x, y1, y1 + h, color); + + } + + return (result); +} + +int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (vlineColor(dst, x, y1, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- Rectangle */ + +int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + int result; + Sint16 w, h, xtmp, ytmp; + + /* + * Swap x1, x2 if required + */ + if (x1 > x2) { + xtmp = x1; + x1 = x2; + x2 = xtmp; + } + + /* + * Swap y1, y2 if required + */ + if (y1 > y2) { + ytmp = y1; + y1 = y2; + y2 = ytmp; + } + + /* + * Calculate width&height + */ + w = x2 - x1; + h = y2 - y1; + + /* + * Sanity check + */ + if ((w < 0) || (h < 0)) { + return (0); + } + + /* + * Test for special cases of straight lines or single point + */ + if (x1 == x2) { + if (y1 == y2) { + return (pixelColor(dst, x1, y1, color)); + } else { + return (vlineColor(dst, x1, y1, y2, color)); + } + } else { + if (y1 == y2) { + return (hlineColor(dst, x1, x2, y1, color)); + } + } + + /* + * Draw rectangle + */ + result = 0; + result |= hlineColor(dst, x1, x2, y1, color); + result |= hlineColor(dst, x1, x2, y2, color); + y1 += 1; + y2 -= 1; + if (y1<=y2) { + result |= vlineColor(dst, x1, y1, y2, color); + result |= vlineColor(dst, x2, y1, y2, color); + } + return (result); + +} + +int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (rectangleColor + (dst, x1, y1, x2, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* --------- Clipping routines for line */ + +/* Clipping based heavily on code from */ +/* http://www.ncsa.uiuc.edu/Vis/Graphics/src/clipCohSuth.c */ + +#define CLIP_LEFT_EDGE 0x1 +#define CLIP_RIGHT_EDGE 0x2 +#define CLIP_BOTTOM_EDGE 0x4 +#define CLIP_TOP_EDGE 0x8 +#define CLIP_INSIDE(a) (!a) +#define CLIP_REJECT(a,b) (a&b) +#define CLIP_ACCEPT(a,b) (!(a|b)) + +static int clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom) +{ + int code = 0; + + if (x < left) { + code |= CLIP_LEFT_EDGE; + } else if (x > right) { + code |= CLIP_RIGHT_EDGE; + } + if (y < top) { + code |= CLIP_TOP_EDGE; + } else if (y > bottom) { + code |= CLIP_BOTTOM_EDGE; + } + return code; +} + +static int clipLine(SDL_Surface * dst, Sint16 * x1, Sint16 * y1, Sint16 * x2, Sint16 * y2) +{ + Sint16 left, right, top, bottom; + int code1, code2; + int draw = 0; + Sint16 swaptmp; + float m; + + /* + * Get clipping boundary + */ + left = dst->clip_rect.x; + right = dst->clip_rect.x + dst->clip_rect.w - 1; + top = dst->clip_rect.y; + bottom = dst->clip_rect.y + dst->clip_rect.h - 1; + + while (1) { + code1 = clipEncode(*x1, *y1, left, top, right, bottom); + code2 = clipEncode(*x2, *y2, left, top, right, bottom); + if (CLIP_ACCEPT(code1, code2)) { + draw = 1; + break; + } else if (CLIP_REJECT(code1, code2)) + break; + else { + if (CLIP_INSIDE(code1)) { + swaptmp = *x2; + *x2 = *x1; + *x1 = swaptmp; + swaptmp = *y2; + *y2 = *y1; + *y1 = swaptmp; + swaptmp = code2; + code2 = code1; + code1 = swaptmp; + } + if (*x2 != *x1) { + m = (*y2 - *y1) / (float) (*x2 - *x1); + } else { + m = 1.0f; + } + if (code1 & CLIP_LEFT_EDGE) { + *y1 += (Sint16) ((left - *x1) * m); + *x1 = left; + } else if (code1 & CLIP_RIGHT_EDGE) { + *y1 += (Sint16) ((right - *x1) * m); + *x1 = right; + } else if (code1 & CLIP_BOTTOM_EDGE) { + if (*x2 != *x1) { + *x1 += (Sint16) ((bottom - *y1) / m); + } + *y1 = bottom; + } else if (code1 & CLIP_TOP_EDGE) { + if (*x2 != *x1) { + *x1 += (Sint16) ((top - *y1) / m); + } + *y1 = top; + } + } + } + + return draw; +} + +/* ----- Filled rectangle (Box) */ + +int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + Sint16 left, right, top, bottom; + Uint8 *pixel, *pixellast; + int x, dx; + int dy; + int pixx, pixy; + Sint16 w, h, tmp; + int result; + Uint8 *colorptr; + + /* + * Get clipping boundary + */ + left = dst->clip_rect.x; + right = dst->clip_rect.x + dst->clip_rect.w - 1; + top = dst->clip_rect.y; + bottom = dst->clip_rect.y + dst->clip_rect.h - 1; + + /* Check visibility */ + if ((x1<left) && (x2<left)) { + return(0); + } + if ((x1>right) && (x2>right)) { + return(0); + } + if ((y1<top) && (y2<top)) { + return(0); + } + if ((y1>bottom) && (y2>bottom)) { + return(0); + } + + /* Clip all points */ + if (x1<left) { + x1=left; + } else if (x1>right) { + x1=right; + } + if (x2<left) { + x2=left; + } else if (x2>right) { + x2=right; + } + if (y1<top) { + y1=top; + } else if (y1>bottom) { + y1=bottom; + } + if (y2<top) { + y2=top; + } else if (y2>bottom) { + y2=bottom; + } + + /* + * Order coordinates + */ + if (x1 > x2) { + tmp = x1; + x1 = x2; + x2 = tmp; + } + if (y1 > y2) { + tmp = y1; + y1 = y2; + y2 = tmp; + } + + /* + * Test for special cases of straight line or single point + */ + if (x1 == x2) { + if (y1 == y2) { + return (pixelColor(dst, x1, y1, color)); + } else { + return (vlineColor(dst, x1, y1, y2, color)); + } + } + if (y1 == y2) { + return (hlineColor(dst, x1, x2, y1, color)); + } + + + /* + * Calculate width&height + */ + w = x2 - x1; + h = y2 - y1; + + /* + * Alpha check + */ + if ((color & 255) == 255) { + + /* + * No alpha-blending required + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + /* + * Lock surface + */ + SDL_LockSurface(dst); + + /* + * More variable setup + */ + dx = w; + dy = h; + pixx = dst->format->BytesPerPixel; + pixy = dst->pitch; + pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y1; + pixellast = pixel + pixx * dx + pixy * dy; + dx++; + + /* + * Draw + */ + switch (dst->format->BytesPerPixel) { + case 1: + for (; pixel <= pixellast; pixel += pixy) { + memset(pixel, (Uint8) color, dx); + } + break; + case 2: + pixy -= (pixx * dx); + for (; pixel <= pixellast; pixel += pixy) { + for (x = 0; x < dx; x++) { + *(Uint16 *) pixel = color; + pixel += pixx; + } + } + break; + case 3: + pixy -= (pixx * dx); + for (; pixel <= pixellast; pixel += pixy) { + for (x = 0; x < dx; x++) { + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + pixel += pixx; + } + } + break; + default: /* case 4 */ + pixy -= (pixx * dx); + for (; pixel <= pixellast; pixel += pixy) { + for (x = 0; x < dx; x++) { + *(Uint32 *) pixel = color; + pixel += pixx; + } + } + break; + } + + /* + * Unlock surface + */ + SDL_UnlockSurface(dst); + + result = 0; + + } else { + + result = filledRectAlpha(dst, x1, y1, x1 + w, y1 + h, color); + + } + + return (result); +} + +int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (boxColor(dst, x1, y1, x2, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- Line */ + +/* Non-alpha line drawing code adapted from routine */ +/* by Pete Shinners, pe...@sh... */ +/* Originally from pygame, http://pygame.seul.org */ + +#define ABS(a) (((a)<0) ? -(a) : (a)) + +int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + int pixx, pixy; + int x, y; + int dx, dy; + int ax, ay; + int sx, sy; + int swaptmp; + Uint8 *pixel; + Uint8 *colorptr; + + /* + * Clip line and test if we h... [truncated message content] |
From: <eX...@us...> - 2007-03-26 15:05:16
|
Revision: 11 http://qonk.svn.sourceforge.net/qonk/?rev=11&view=rev Author: eXinion Date: 2007-03-26 07:59:47 -0700 (Mon, 26 Mar 2007) Log Message: ----------- Modified Paths: -------------- branches/networked_original_2007-03-26/server/main.cpp Modified: branches/networked_original_2007-03-26/server/main.cpp =================================================================== --- branches/networked_original_2007-03-26/server/main.cpp 2007-03-26 14:55:05 UTC (rev 10) +++ branches/networked_original_2007-03-26/server/main.cpp 2007-03-26 14:59:47 UTC (rev 11) @@ -44,11 +44,12 @@ state = STARTUP; int numberOfPlayers = 2; + int numberOfPlanets = 4; if (argc >= 2) { numberOfPlayers = atoi(argv[1]); + numberOfPlanets = numberOfPlayers*2; } - int numberOfPlanets = 4; if (argc >= 3) { numberOfPlanets = atoi(argv[2]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-03-26 14:20:53
|
Revision: 9 http://qonk.svn.sourceforge.net/qonk/?rev=9&view=rev Author: thebohemian Date: 2007-03-26 07:20:51 -0700 (Mon, 26 Mar 2007) Log Message: ----------- Created a private branch of qonk which has the aim of adding GNU autoconf support. Modified Paths: -------------- trunk/Makefile Added Paths: ----------- branches/ branches/autoconf-2007-03-26-thebohemian/ branches/autoconf-2007-03-26-thebohemian/BRANCH-README Copied: branches/autoconf-2007-03-26-thebohemian (from rev 8, trunk) Added: branches/autoconf-2007-03-26-thebohemian/BRANCH-README =================================================================== --- branches/autoconf-2007-03-26-thebohemian/BRANCH-README (rev 0) +++ branches/autoconf-2007-03-26-thebohemian/BRANCH-README 2007-03-26 14:20:51 UTC (rev 9) @@ -0,0 +1,11 @@ +About this branch +----------------- + +This development branch has been created on 2007-03-26 by +thebohemian/Robert Schuster in order to integrate GNU Autoconf & +GNU Automake into Qonk. + +Status: +------- + +- Planning, nothing has been changed yet. Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2007-03-22 20:30:12 UTC (rev 8) +++ trunk/Makefile 2007-03-26 14:20:51 UTC (rev 9) @@ -1,5 +1,5 @@ -PREFIX=/usr/local/share/games -BIN=/usr/local/bin +PREFIX=/home/rob/INSTALL/qonk +BIN=/home/rob/INSTALL/qonk/bin CXX=g++ CFLAGS=`sdl-config --cflags` -O3 @@ -45,6 +45,7 @@ install: all mkdir -p $(PREFIX)/qonk + mkdir -p $(BIN) cp qonk $(PREFIX)/qonk/ cp font.ttf $(PREFIX)/qonk/ cp qonk.conf $(PREFIX)/qonk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ali...@us...> - 2007-03-22 20:27:44
|
Revision: 7 http://qonk.svn.sourceforge.net/qonk/?rev=7&view=rev Author: aliekens Date: 2007-03-22 13:27:38 -0700 (Thu, 22 Mar 2007) Log Message: ----------- * Fixed bug that checked whether requested config existed, but didn't compile Modified Paths: -------------- trunk/ReadConf.cpp Modified: trunk/ReadConf.cpp =================================================================== --- trunk/ReadConf.cpp 2007-03-22 14:55:12 UTC (rev 6) +++ trunk/ReadConf.cpp 2007-03-22 20:27:38 UTC (rev 7) @@ -20,7 +20,7 @@ std::string Config::getValue( const std::string& parameter ) const { std::map< std::string, std::string >::const_iterator i = data.find( parameter ); - if( i != NULL ) + if( i != data.end() ) return i->second; else return ""; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |