# HG changeset patch # User Tero Marttila # Date 1232589197 -7200 # Node ID 947ab54de4b7a9b2189cb9c46ffad0183012ad98 # Parent 5e4c8631779e6f29ea35a453821f381ec8212217 fix worst compilation errors when using the debian lenny gcc/libc... diff -r 5e4c8631779e -r 947ab54de4b7 src/Config.hh --- a/src/Config.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Config.hh Thu Jan 22 03:53:17 2009 +0200 @@ -13,8 +13,9 @@ // custom types #include "Types.hh" -// for CL_Color -#include +// for Color +#include "Graphics/Color.hh" +using graphics::Color; /** * @name General @@ -35,13 +36,13 @@ const PixelDimensions TERRAIN_DIMENSIONS (1000, 800); /** Base color of empty space (i.e. background color) */ -const CL_Color COLOR_EMPTY(86, 41, 0); +const Color COLOR_EMPTY(86, 41, 0); /** Base color of dirt */ -const CL_Color COLOR_DIRT(144, 82, 23); +const Color COLOR_DIRT(144, 82, 23); /** Base color of rock */ -const CL_Color COLOR_ROCK(132, 136, 135); +const Color COLOR_ROCK(132, 136, 135); // @} @@ -65,7 +66,7 @@ */ /** The value of pi used in physics/graphics calculations */ -const float KG_PI = 3.14159265; +const float KG_PI = 3.14159265f; /** Physics tick interval */ const TimeMS PHYSICS_TICK_MS = 10; @@ -84,13 +85,13 @@ const float PLAYER_MOVE_FORCE = 1100.0; const float PLAYER_MIN_SPEED = 10.0; const float PLAYER_JUMP_MIN_DISTANCE = 5.0; -const float PLAYER_AIM_MIN = -3*KG_PI/8; -const float PLAYER_AIM_MAX = KG_PI/2; +const float PLAYER_AIM_MIN = -3 * KG_PI / 8; +const float PLAYER_AIM_MAX = KG_PI / 2; const float PLAYER_INITIAL_X = 400.0; const float PLAYER_INITIAL_Y = 300.0; const float PLAYER_CROSSHAIR_DISTANCE = 20.0; const float PLAYER_CROSSHAIR_WIDTH = 4; -const float CROSSHAIR_ANGLE_SPEED = PI/2000; +const float CROSSHAIR_ANGLE_SPEED = KG_PI / 2000; const float PLAYER_MAX_SPEED = 43; const float PLAYER_WALK_SPEED = 33; const float PLAYER_COLLISION_ELASTICITY = 0.25; @@ -143,8 +144,8 @@ /** * Rope colors, it should alternate between these two */ -const CL_Color ROPE_COLOR_LIGHT = CL_Color(198, 100, 2); -const CL_Color ROPE_COLOR_DARK = CL_Color(159, 79, 1); +const Color ROPE_COLOR_LIGHT(198, 100, 2); +const Color ROPE_COLOR_DARK(159, 79, 1); // @} diff -r 5e4c8631779e -r 947ab54de4b7 src/Engine.cc --- a/src/Engine.cc Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Engine.cc Thu Jan 22 03:53:17 2009 +0200 @@ -14,6 +14,7 @@ #if GRAPHICS_ENABLED #include "Graphics/Graphics.hh" + #include "Graphics/GameView.hh" #endif #include @@ -107,6 +108,10 @@ void Engine::setupNetworkClient (const std::string &connect_host, const std::string &connect_port) { #if NETWORK_ENABLED + // client operation requires graphics + if (!GRAPHICS_ENABLED) + throw Error("Network client mode requires graphics support"); + // connect_to NetworkEndpoint connect_addr(connect_host, connect_port); @@ -137,8 +142,10 @@ startGameView(lp); } +GameState& Engine::onNetworkClientConnected (Terrain *terrain) { + // sanity-check + assert(!terrain && !game_state && graphics); -GameState& Engine::onNetworkClientConnected (Terrain *terrain) { // setup the game setupGame(terrain); @@ -148,12 +155,22 @@ // return GameState return *game_state; } - + void Engine::onNetworkClientPlayer (LocalPlayer *player) { + +#if GRAPHICS_ENABLED assert(game_view); // set the GameView's player game_view->setPlayer(player); + +#else + (void) player; + + assert(graphics); + +#endif + } void Engine::stop (void) { diff -r 5e4c8631779e -r 947ab54de4b7 src/GameState.cc --- a/src/GameState.cc Thu Jan 22 03:19:25 2009 +0200 +++ b/src/GameState.cc Thu Jan 22 03:53:17 2009 +0200 @@ -5,7 +5,7 @@ #include "Error.hh" GameState::GameState (Terrain &terrain) : - world(Vector(0, MAP_GRAVITY), Vector(terrain.getWidth(), terrain.getHeight()), terrain), + world(Vector(0, MAP_GRAVITY), Vector((float) terrain.getWidth(), (float) terrain.getHeight()), terrain), terrain(terrain), local_player(NULL), event_handler(NULL) { diff -r 5e4c8631779e -r 947ab54de4b7 src/Graphics/Color.hh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Graphics/Color.hh Thu Jan 22 03:53:17 2009 +0200 @@ -0,0 +1,37 @@ +#ifndef GRAPHICS_COLOR_HH +#define GRAPHICS_COLOR_HH + +#if GRAPHICS_ENABLED + +#include + +namespace graphics +{ + +// alias +typedef CL_Color Color; + +} + +# else /* GRAPHICS_ENABLED */ + +namespace graphics +{ + +/** + * XXX: define dummy color type for use when graphics are disabled + */ +class Color { +public: + Color (unsigned red, unsigned green, unsigned blue) + { + (void) red; + (void) green; + (void) blue; + } +}; + +} +#endif /* GRAPHICS_ENABLED */ + +#endif /* GRAPHICS_COLOR_HH */ diff -r 5e4c8631779e -r 947ab54de4b7 src/Graphics/Display.hh --- a/src/Graphics/Display.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Graphics/Display.hh Thu Jan 22 03:53:17 2009 +0200 @@ -11,6 +11,9 @@ } +// XXX: ugly hack +#if GRAPHICS_ENABLED + #include "View.hh" #include "../Timer.hh" #include "../Configuration.hh" @@ -99,4 +102,6 @@ } -#endif +#endif /* GRAPHICS_ENABLED */ + +#endif /* GRAPHICS_ENABLED */ diff -r 5e4c8631779e -r 947ab54de4b7 src/Graphics/Drawable.hh --- a/src/Graphics/Drawable.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Graphics/Drawable.hh Thu Jan 22 03:53:17 2009 +0200 @@ -1,4 +1,6 @@ -#ifndef GRAPHICS_DRAWABLE_HH + +// XXX: because this is included from .. +#if GRAPHICS_ENABLED && !(defined GRAPHICS_DRAWABLE_HH) #define GRAPHICS_DRAWABLE_HH namespace graphics diff -r 5e4c8631779e -r 947ab54de4b7 src/Graphics/Graphics.hh --- a/src/Graphics/Graphics.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Graphics/Graphics.hh Thu Jan 22 03:53:17 2009 +0200 @@ -1,4 +1,5 @@ -#ifndef GRAPHICS_GRAPHICS_HH +// XXX: ugly hack +#if GRAPHICS_ENABLED && !(defined GRAPHICS_GRAPHICS_HH) #define GRAPHICS_GRAPHICS_HH namespace graphics diff -r 5e4c8631779e -r 947ab54de4b7 src/Network/Address.hh --- a/src/Network/Address.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Network/Address.hh Thu Jan 22 03:53:17 2009 +0200 @@ -10,6 +10,8 @@ #include "Platform.hh" #include "Endpoint.hh" +#include + /** * A NetworkAddress represents a single network address in the form of a `struct sockaddr`, as used by the OS's socket * API. A NetworkAddress's value may only be constructed/manipulated in sockaddr form, and the class then emulates the diff -r 5e4c8631779e -r 947ab54de4b7 src/Network/Error.cc --- a/src/Network/Error.cc Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Network/Error.cc Thu Jan 22 03:53:17 2009 +0200 @@ -1,7 +1,7 @@ #include "Error.hh" +#include "Platform.hh" -#include #include std::string NetworkErrno::build_str (std::string op, int err) { diff -r 5e4c8631779e -r 947ab54de4b7 src/Network/Packet.hh --- a/src/Network/Packet.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Network/Packet.hh Thu Jan 22 03:53:17 2009 +0200 @@ -7,8 +7,8 @@ * Provides the NetworkPackets that are used to communicate over a NetworkTCP/NetworkUDP sockets. */ +#include "../Types.hh" #include "../Config.hh" -#include "../Types.hh" #include "../Error.hh" /** diff -r 5e4c8631779e -r 947ab54de4b7 src/Network/Platform.hh --- a/src/Network/Platform.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Network/Platform.hh Thu Jan 22 03:53:17 2009 +0200 @@ -30,6 +30,10 @@ #include #include #include + + // NetworkErrno + #include + #include #else // misc, here because ClanLib included these... #include diff -r 5e4c8631779e -r 947ab54de4b7 src/PhysicsObject.hh --- a/src/PhysicsObject.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/PhysicsObject.hh Thu Jan 22 03:53:17 2009 +0200 @@ -1,8 +1,6 @@ #ifndef PHYSICS_OBJECT_HH #define PHYSICS_OBJECT_HH -#include -#include // Forward declares class PhysicsObject; @@ -13,6 +11,9 @@ #include "Timer.hh" #include "Config.hh" +#include +#include + // Type definitions typedef Vector Force; diff -r 5e4c8631779e -r 947ab54de4b7 src/PhysicsWorld.cc --- a/src/PhysicsWorld.cc Thu Jan 22 03:19:25 2009 +0200 +++ b/src/PhysicsWorld.cc Thu Jan 22 03:53:17 2009 +0200 @@ -2,7 +2,9 @@ #include "PhysicsWorld.hh" #include "Engine.hh" +#include #include +#include PhysicsWorld::PhysicsWorld (Vector gravity, Vector dimensions, Terrain &terrain) : terrain(terrain), diff -r 5e4c8631779e -r 947ab54de4b7 src/PhysicsWorld.hh --- a/src/PhysicsWorld.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/PhysicsWorld.hh Thu Jan 22 03:53:17 2009 +0200 @@ -1,13 +1,6 @@ #ifndef PHYSICS_WORLD_HH #define PHYSICS_WORLD_HH -#include -#include - -#include -#include -#include - #include "Terrain.hh" class PhysicsWorld; @@ -17,6 +10,8 @@ #include "Timer.hh" #include "Config.hh" +#include + /** * PhysicsWorld class. PhysicsWorld contains a number of PhysicsObjects that are simulated forward in time using * the physics tick rate diff -r 5e4c8631779e -r 947ab54de4b7 src/Player.cc --- a/src/Player.cc Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Player.cc Thu Jan 22 03:53:17 2009 +0200 @@ -3,15 +3,16 @@ #include "Weapons.hh" #include "Engine.hh" -#include "Graphics/Graphics.hh" - #include -#include #include #include #include #if GRAPHICS_ENABLED + +#include +#include "Graphics/Graphics.hh" + /* * Static draw-related state */ diff -r 5e4c8631779e -r 947ab54de4b7 src/Terrain.cc --- a/src/Terrain.cc Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Terrain.cc Thu Jan 22 03:53:17 2009 +0200 @@ -3,10 +3,18 @@ #include "Engine.hh" #include +#include #include #include + +#if GRAPHICS_ENABLED + +#include "Graphics/Drawable.hh" + #include +#endif + const Vector DIRECTIONS[] = { Vector(0,-1), Vector(1,-1), @@ -124,6 +132,8 @@ } +// XXX: disable textures as well +#if GRAPHICS_ENABLED /* * Texture generation utility functions */ @@ -219,8 +229,8 @@ return val; } -CL_Color Terrain::getTexturePixel (PixelDimension x, PixelDimension y) { - CL_Color color; +Color Terrain::getTexturePixel (PixelDimension x, PixelDimension y) { + Color color; int texture_fade = 8; // determine fade constant @@ -255,12 +265,13 @@ blue += (texture[tx][ty] - 128) / texture_fade; // normalize colors to within range and return new color - return CL_Color( + return Color( normalizeRange(0, red, 255), normalizeRange(0, green, 255), normalizeRange(0, blue, 255) ); } +#endif /* GRAPHICS_ENABLED */ const TerrainPixel* Terrain::getTerrainBuffer (void) const { return terrain_buf; diff -r 5e4c8631779e -r 947ab54de4b7 src/Terrain.hh --- a/src/Terrain.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Terrain.hh Thu Jan 22 03:53:17 2009 +0200 @@ -6,8 +6,6 @@ #include "Config.hh" #include "Configuration.hh" -#include "Graphics/Drawable.hh" - #include /** @@ -117,7 +115,7 @@ * Applies noise generated using generateTexture to generate a slightly varying color for the terrain pixel * at \a pc. */ - CL_Color getTexturePixel (PixelDimension x, PixelDimension y); + Color getTexturePixel (PixelDimension x, PixelDimension y); /** * Scale parameter to "pixels" diff -r 5e4c8631779e -r 947ab54de4b7 src/Timer.cc --- a/src/Timer.cc Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Timer.cc Thu Jan 22 03:53:17 2009 +0200 @@ -50,7 +50,9 @@ // update state last_tick = now; - ticks += tick_length / interval; + + // XXX: handle overflow + ticks += (TickCount) tick_length / interval; // if it was single-shot, disable if (single_shot) diff -r 5e4c8631779e -r 947ab54de4b7 src/Vector.hh --- a/src/Vector.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Vector.hh Thu Jan 22 03:53:17 2009 +0200 @@ -208,8 +208,8 @@ * Float/int absolute value */ template static T absType (T value); -template<> static float absType (float value) { return fabs(value); } -template<> static long absType (long value) { return labs(value); } +template<> float absType (float value) { return (float) fabs(value); } +template<> long absType (long value) { return labs(value); } /** * Direction-normalize the given coordinate against the tangent coordinate. diff -r 5e4c8631779e -r 947ab54de4b7 src/Weapon.hh --- a/src/Weapon.hh Thu Jan 22 03:19:25 2009 +0200 +++ b/src/Weapon.hh Thu Jan 22 03:53:17 2009 +0200 @@ -68,9 +68,9 @@ TickCount expire; /** - * current reload state + * Remaining reload time */ - int reloadTimer; + TimeMS reloadTimer; /** * If nonzero, projectiles bounce off walls (it's the elasticity factor), else they explode on contact @@ -106,14 +106,17 @@ float getSpeed (void) const { return velocity; } float getRecoil (void) const { return recoil; } float getExplosionRadius (void) const { return explosionRadius; } - int getDamage (void) const { return damage; } + + // XXX: int -> Health + Health getDamage (void) const { return (Health) damage; } float getRadius (void) const { return radius; } TickCount getExpire (void) const { return expire; } float getBounce (void) const { return bounce; } float getMass (void) const { return mass; } - - int getReloadTimer(void) const { return reloadTimer; } - int getReloadTime(void) const { return reloadTime; } + + // XXX: remove one of these + TimeMS getReloadTimer(void) const { return reloadTimer; } + TimeMS getReloadTime(void) const { return reloadTime; } /** * Start reloading