liblashgame

Pathfinder and path decision making library for 2D tile game
git clone git://holbrook.no/liblashgame.git
Log | Files | Refs

commit 6a8cd6706f1f038e05acc3b8311c43a5415e9182
Author: lash <dev@holbrook.no>
Date:   Sat, 12 Nov 2022 10:36:24 +0000

Initial commit for state 20.05.2018

Diffstat:
Ac++/lash_game_sprite.cpp | 422+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ac++/lash_game_sprite.h | 150+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ac++/tests/fallbounceline.cpp | 523+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ac++/tests/fallbounceline.dat | 3+++
Ac++/tests/iswalking.cpp | 20++++++++++++++++++++
Ac++/tests/slopeaccel.cpp | 234+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ac++/tests/slopecollide.cpp | 333+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ac++/tests/slopejump.cpp | 237+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ac++/tests/sprite.cpp | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ac++/tests/spritesetvel.cpp | 46++++++++++++++++++++++++++++++++++++++++++++++
Aconfigure.in | 5568+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acpython/lash_game_map_setup.py | 18++++++++++++++++++
Acpython/lash_game_map_wrapper.c | 310+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acpython/lash_game_standard_setup.py | 16++++++++++++++++
Acpython/lash_game_standard_wrapper.c | 235+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alash_game_color.c | 5+++++
Alash_game_color.h | 16++++++++++++++++
Alash_game_map.c | 130+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alash_game_map.h | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alash_game_path_simple.c | 312+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alash_game_path_simple.h | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alash_game_standard.c | 476+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alash_game_standard.h | 157+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aold/lash_game_path.c | 228+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aold/lash_game_path.h | 196+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aold/tmp_collision.c | 220+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/anglespan.c | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/cartesianfloat.c | 26++++++++++++++++++++++++++
Atests/cartesianindex.c | 45+++++++++++++++++++++++++++++++++++++++++++++
Atests/cartesianlinear.c | 28++++++++++++++++++++++++++++
Atests/cartesianpolar.c | 39+++++++++++++++++++++++++++++++++++++++
Atests/circleline.c | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/containedangle.c | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/findpath.c | 129+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/getfreespace.c | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/getquadrant.c | 15+++++++++++++++
Atests/include/common.c | 42++++++++++++++++++++++++++++++++++++++++++
Atests/include/common.h | 7+++++++
Atests/linear.c | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/log.txt | 2598+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/manhattan.c | 30++++++++++++++++++++++++++++++
Atests/map.c | 28++++++++++++++++++++++++++++
Atests/mapclip.c | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/mapcolor.c | 31+++++++++++++++++++++++++++++++
Atests/mapdata.txt | 11+++++++++++
Atests/mapdata_impossible.txt | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/normalizequadrantradians.c | 15+++++++++++++++
Atests/normalizeradians.c | 14++++++++++++++
Atests/pathcheckmodifier.c | 48++++++++++++++++++++++++++++++++++++++++++++++++
Atests/pathfindfreesquare.c | 247+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/pathsimple.c | 40++++++++++++++++++++++++++++++++++++++++
Atests/pathsimpledemo.c | 357+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/polarcartesian.c | 26++++++++++++++++++++++++++
Atests/surfacecollision.c | 24++++++++++++++++++++++++
54 files changed, 14349 insertions(+), 0 deletions(-)

diff --git a/c++/lash_game_sprite.cpp b/c++/lash_game_sprite.cpp @@ -0,0 +1,422 @@ +#include <stdint.h> +#include <string.h> +#include <stdio.h> +#include <math.h> +#include "lash_game_sprite.h" +#include "liblashgame/lash_game_standard.h" + +/// \todo allow velocity formulas for arcs, circle, bezier +/// \todo flip friction modifiers for negative acceleration + +Lash_Sprite_2D_Simple::Lash_Sprite_2D_Simple() { +} + +Lash_Sprite_2D_Simple::Lash_Sprite_2D_Simple(const uint32_t initw, const uint32_t inith, const float inita, const float inca) { + init(initw, inith, inita, inca); +} + +int Lash_Sprite_2D_Simple::init(const uint32_t initw, const uint32_t inith, const float inita, const float inca) { + h = inith; + w = initw; + clear(); + a_init = inita; + a = inca; + return 0; +} + +void Lash_Sprite_2D_Simple::clear() { + coords.x = 0.f; + coords.y = 0.f; + v = 0.f; + rv = 0.f; + ra = 0.f; + m = 0.f; + f = 0.f; + state = LASH_GAME_SPRITE_SIMPLE_STATE_STILL; +} + +int32_t Lash_Sprite_2D_Simple::getXPixels() { + return round(coords.x); +} + +float Lash_Sprite_2D_Simple::getX() { + return coords.x; +} + +void Lash_Sprite_2D_Simple::setX(const int32_t newx) { + coords.x = (float)newx; +} + +void Lash_Sprite_2D_Simple::setX(const float newx) { + coords.x = newx; +} + +int32_t Lash_Sprite_2D_Simple::getYPixels() { + return round(coords.y); +} + +float Lash_Sprite_2D_Simple::getY() { + return coords.y; +} + +void Lash_Sprite_2D_Simple::setY(const int32_t newy) { + coords.y = (float)newy; +} + +void Lash_Sprite_2D_Simple::setY(const float newy) { + coords.y = newy; +} + +int32_t Lash_Sprite_2D_Simple::getW() { + return w; +} + +int32_t Lash_Sprite_2D_Simple::getH() { + return h; +} + +void Lash_Sprite_2D_Simple::setResistance(float newf) { + f = newf; +} + +float Lash_Sprite_2D_Simple::getResistance() { + return f; +} + +void Lash_Sprite_2D_Simple::setAccelerationX(float newa) { + if (newa < 0) { + a = -newa; + ra = M_PI; + } else { + a = newa; + ra = 0.f; + } +} + +void Lash_Sprite_2D_Simple::setAccelerationY(float newa) { + if (newa < 0) { + a = -newa; + ra = M_PI_2; + } else { + a = newa; + ra = 3 * M_PI_2; + } +} + +void Lash_Sprite_2D_Simple::setAcceleration(float newa, float newr) { + a = newa; + ra = newr; +} + +void Lash_Sprite_2D_Simple::addAcceleration(float inca, float r) { + float newx = (cos(ra) * a) + (cos(r) * inca); + float newy = (-sin(ra) * a) + (sin(r) * inca); + ra = atan2(newy, newx); + a = sqrt(pow(newx,2) + pow(newy,2)); +} + +void Lash_Sprite_2D_Simple::addAccelerationX(float inca) { + float newx = (cos(ra) * a) + inca; + float newy = (sin(ra) * a); + ra = atan2(-newy, newx); + a = sqrt(pow(newx,2) + pow(newy,2)); +} + +void Lash_Sprite_2D_Simple::addAccelerationY(float inca) { + float newx = (cos(ra) * a); + float newy = (sin(ra) * a) + inca; + ra = atan2(-newy, newx); + a = sqrt(pow(newx,2) + pow(newy,2)); +} + +void Lash_Sprite_2D_Simple::getAcceleration(float *vslot, float *rslot, int noresistance) { + if (noresistance) + *vslot = a; + else + *vslot = a - f; + *rslot = lashNormalizeRadians(ra); +} + +float Lash_Sprite_2D_Simple::getAccelerationX(int noresistance) { + if (noresistance) + return cos(ra) * a; + return cos(ra) * (a - f); +} + +float Lash_Sprite_2D_Simple::getAccelerationY(int noresistance) { + if (noresistance) + return sin(ra) * a; + return sin(ra) * (a - f); +} + +float Lash_Sprite_2D_Simple::getAccelerationRadians() { + return ra; +} + +void Lash_Sprite_2D_Simple::setVel(float newv, float newr) { + v = newv; + rv = newr; +} + +void Lash_Sprite_2D_Simple::setVelX(float newvx, int keepy = 0) { + if (keepy) { + float oldvy = getVelY(); + v = sqrt(pow(newvx, 2) + pow(oldvy, 2)); + rv = atan(oldvy / newvx); + } else { + if (newvx < 0) { + v = -newvx; + rv = M_PI; + } else { + v = newvx; + rv = 0.f; + } + } +} + +void Lash_Sprite_2D_Simple::addVel(float incv, float r) { + float newx = (cos(rv) * v) + (cos(r) * incv); + //float newy = (-sin(rv) * v) + (sin(r) * incv); + float newy = (sin(rv) * v) + (sin(r) * incv); + rv = atan2(newy, newx); + v = sqrt(pow(newx,2) + pow(newy,2)); +} + +float Lash_Sprite_2D_Simple::getVel() { + return v; +} + +void Lash_Sprite_2D_Simple::getVel(float *retv, float *retr) { + *retv = v; + *retr = lashNormalizeRadians(rv); +} + +float Lash_Sprite_2D_Simple::getVelRadians() { + return rv; +} + +float Lash_Sprite_2D_Simple::getVelX() { + return cos(rv) * v; +} + +void Lash_Sprite_2D_Simple::setVelY(float newvy, int keepx = 0) { + if (keepx) { + float oldvx = getVelX(); + v = sqrt(pow(oldvx, 2) + pow(newvy, 2)); + rv = atan(-newvy / oldvx); + } else { + if (newvy < 0) { + v = -newvy; + rv = M_PI_2; + } else { + v = newvy; + rv = 3 * M_PI_2; + } + } +} + +float Lash_Sprite_2D_Simple::getVelY() { + return sin(rv) * v; +} + +void Lash_Sprite_2D_Simple::setMass(float newm) { + m = newm; +} + +float Lash_Sprite_2D_Simple::getMass() { + return m; +} + +int32_t Lash_Sprite_2D_Simple::getNextXPixels() { + return (int32_t)(coords.x + (cos(rv) * v)); +} + +float Lash_Sprite_2D_Simple::getNextX() { + return coords.x + (cos(rv) * v); +} + +int32_t Lash_Sprite_2D_Simple::getNextYPixels() { + return (int32_t)(coords.y + (sin(rv) * v)); +} + +float Lash_Sprite_2D_Simple::getNextY() { + return coords.y + (sin(rv) * v); +} + +void Lash_Sprite_2D_Simple::move() { + coords.x += cos(rv) * v; + coords.y += -sin(rv) * v; +} + +void Lash_Sprite_2D_Simple::moveX() { + coords.x += cos(rv) * v; +} + +void Lash_Sprite_2D_Simple::moveY() { + coords.y += -sin(rv) * v; +} + +void Lash_Sprite_2D_Simple::moveBy(const lash_game_coords_float_t addcoords) { + coords.x += addcoords.x; + coords.y += addcoords.y; +} + +void Lash_Sprite_2D_Simple::moveBy(float m, float r) { + coords.x += cos(r) * m; + coords.y += -sin(r) * m; +} + +void Lash_Sprite_2D_Simple::accelerate() { + /*if (state & LASH_GAME_SPRITE_SIMPLE_STATE_LEFT || state & LASH_GAME_SPRITE_SIMPLE_STATE_RIGHT) { + if (vx < 0.f) + vx -= ax; + else + vx += ax; + } + if (state & LASH_GAME_SPRITE_SIMPLE_STATE_UP || state & LASH_GAME_SPRITE_SIMPLE_STATE_DOWN) { + if (vy < 0.f) + vy -= ay; + else + vy += ay; + }*/ + + + //double newvx = (cos(ra) * (a - (cos(ra) * f))) + (cos(rv) * v); + //double newvy = (sin(ra) * (a - (sin(ra) * f))) + (sin(rv) * v); + double newvx = (cos(ra) * a) + (cos(rv) * v); + double newvy = (sin(ra) * a) + (sin(rv) * v); + rv = atan2(newvy, newvx); + v = sqrt(pow(newvx, 2) + pow(newvy, 2)); + v -= f; + + // if the only force acting is friction + if ((a == 0.f || a - f < 0.f) && v <= 0.f) { + v = 0.f; + return; + } +} + +void Lash_Sprite_2D_Simple::still() { + state &= 0; + state |= LASH_GAME_SPRITE_SIMPLE_STATE_STILL; +} + +int Lash_Sprite_2D_Simple::walkLeft(int resetvelocity) { + // check if one can walk, return 1 if not + state &= ~255; + state |= LASH_GAME_SPRITE_SIMPLE_STATE_LEFT; + state |= LASH_GAME_SPRITE_SIMPLE_STATE_WALKING; + if (resetvelocity) { + v = a_init; + rv = M_PI; + } + return 0; +} + +int Lash_Sprite_2D_Simple::walkRight(int resetvelocity) { + // check if one can walk, return 1 if not + state &= ~255; + state |= LASH_GAME_SPRITE_SIMPLE_STATE_RIGHT; + state |= LASH_GAME_SPRITE_SIMPLE_STATE_WALKING; + if (resetvelocity) { + v = a_init; + rv = 0.f; + } + return 0; +} + +void Lash_Sprite_2D_Simple::stop() { + state &= ~254; + state &= ~(255 << 8); +} + + +int Lash_Sprite_2D_Simple::jump() { + if (!isJumping()) { + state |= (LASH_GAME_SPRITE_SIMPLE_STATE_ENTERING | LASH_GAME_SPRITE_SIMPLE_STATE_JUMPING); + return 0; + } + return 1; +} + +int Lash_Sprite_2D_Simple::bounce() { + if (!isBouncing()) { + state &= ~(255 << 24); + state |= LASH_GAME_SPRITE_SIMPLE_STATE_REBOUNDING; + return 0; + } + return 1; +} + +void Lash_Sprite_2D_Simple::land() { + state &= ~(255 << 24); + state |= LASH_GAME_SPRITE_SIMPLE_STATE_EXITING; +} + +void Lash_Sprite_2D_Simple::finish() { + state &= ~(255 << 24); +} + +int Lash_Sprite_2D_Simple::isJumping() { + return state & LASH_GAME_SPRITE_SIMPLE_STATE_JUMPING; +} + +int Lash_Sprite_2D_Simple::isBouncing() { + return state & LASH_GAME_SPRITE_SIMPLE_STATE_BOUNCING; +} + +int Lash_Sprite_2D_Simple::isWalking(uint8_t direction = 0) { + uint32_t cmp = 0; + cmp |= LASH_GAME_SPRITE_SIMPLE_STATE_WALKING; + switch (direction) { + case LASH_GAME_SPRITE_SIMPLE_STATE_LEFT: + cmp |= direction; + break; + case LASH_GAME_SPRITE_SIMPLE_STATE_RIGHT: + cmp |= direction; + break; + case LASH_GAME_SPRITE_SIMPLE_STATE_UP: + cmp |= direction; + break; + case LASH_GAME_SPRITE_SIMPLE_STATE_DOWN: + cmp |= direction; + break; + default: + if (state & cmp) + return 1; + } + + return state == cmp; +} + +void Lash_Sprite_2D_Simple::_old_land() { + // remove all movement types (bytes 2 and 3) + /*state &= ~(LASH_GAME_SPRITE_SIMPLE_STATE_RUNNING | + LASH_GAME_SPRITE_SIMPLE_STATE_CROUCHING | + LASH_GAME_SPRITE_SIMPLE_STATE_CRAWLING | + LASH_GAME_SPRITE_SIMPLE_STATE_JUMPING | + LASH_GAME_SPRITE_SIMPLE_STATE_FLYING | + LASH_GAME_SPRITE_SIMPLE_STATE_SWIMMING | + LASH_GAME_SPRITE_SIMPLE_STATE_CLIMBING | + LASH_GAME_SPRITE_SIMPLE_STATE_IMMERSED | + LASH_GAME_SPRITE_SIMPLE_STATE_ENTERING | + LASH_GAME_SPRITE_SIMPLE_STATE_NOCONTROL | + LASH_GAME_SPRITE_SIMPLE_STATE_REBOUNDING);*/ + state &= ~((255 + (255 << 8)) << 8); + state |= LASH_GAME_SPRITE_SIMPLE_STATE_EXITING; + +} + +// temporary function for debug +void Lash_Sprite_2D_Simple::dumpState(char bitstring[]) { + unsigned int i; + unsigned int skew = 0; + for (i = 0; i < sizeof(uint32_t) * 8; i++) { + if (!(i % 8) && i > 0) { + sprintf(bitstring+skew+i, " "); + skew++; + } + sprintf(bitstring+skew+i, "%d", state >> i & 1); + } + strcat(bitstring, "\0"); +} diff --git a/c++/lash_game_sprite.h b/c++/lash_game_sprite.h @@ -0,0 +1,150 @@ +#ifndef LASH_GAME_SPRITE_SIMPLE_H_ +#define LASH_GAME_SPRITE_SIMPLE_H_ + +#include <stdint.h> +#include "liblashgame/lash_game_standard.h" + +enum states { + // direction + LASH_GAME_SPRITE_SIMPLE_STATE_STILL = (1 << 0), + LASH_GAME_SPRITE_SIMPLE_STATE_LEFT = (1 << 1), + LASH_GAME_SPRITE_SIMPLE_STATE_RIGHT = (1 << 2), + LASH_GAME_SPRITE_SIMPLE_STATE_UP = (1 << 3), + LASH_GAME_SPRITE_SIMPLE_STATE_DOWN = (1 << 4), + LASH_GAME_SPRITE_SIMPLE_STATE_RISE = (1 << 5), + LASH_GAME_SPRITE_SIMPLE_STATE_LOWER = (1 << 6), + // = (1 << 7) + + // movement types + LASH_GAME_SPRITE_SIMPLE_STATE_WALKING = (1 << 8), + LASH_GAME_SPRITE_SIMPLE_STATE_RUNNING = (1 << 9), + LASH_GAME_SPRITE_SIMPLE_STATE_BOUNCING = (1 << 10), + // = (1 << 11) + // = (1 << 12) + // = (1 << 13) + // = (1 << 14) + // = (1 << 15) + + // posture types + LASH_GAME_SPRITE_SIMPLE_STATE_CROUCHING = (1 << 16), + LASH_GAME_SPRITE_SIMPLE_STATE_CRAWLING = (1 << 17), + LASH_GAME_SPRITE_SIMPLE_STATE_JUMPING = (1 << 18), + LASH_GAME_SPRITE_SIMPLE_STATE_FLYING = (1 << 19), + LASH_GAME_SPRITE_SIMPLE_STATE_SWIMMING = (1 << 20), + LASH_GAME_SPRITE_SIMPLE_STATE_CLIMBING = (1 << 21), + // = (1 << 22) + // = (1 << 23) + + // environment types + LASH_GAME_SPRITE_SIMPLE_STATE_IMMERSED = (1 << 24), + LASH_GAME_SPRITE_SIMPLE_STATE_ENTERING = (1 << 25), // for swim, going into water, for jumping launching + LASH_GAME_SPRITE_SIMPLE_STATE_EXITING = (1 << 26), + LASH_GAME_SPRITE_SIMPLE_STATE_NOCONTROL = (1 << 27), // out of control; swimming = sinking, jumping = falling + LASH_GAME_SPRITE_SIMPLE_STATE_REBOUNDING = (1 << 28) + // = (1 << 29) + // = (1 << 30) + // = (1 << 31) + + + }; + +class Lash_Sprite_2D_Simple { + private: + lash_game_coords_float_t coords; + uint32_t w; // width in pixels + uint32_t h; // width in pixels + float v; // velocity + float rv; // radians direction of velocity + float a_init; + float a; // acceleration + float ra; // radians direction of acceleration + float m; // mass (kg) + float f; // friction + enum movements { + LASH_GAME_SPRITE_SIMPLE_MOVEMENT_LINEAR = (1 << 0), + LASH_GAME_SPRITE_SIMPLE_MOVEMENT_ARC = (1 << 1) + }; + uint32_t state; + + public: + Lash_Sprite_2D_Simple(); + Lash_Sprite_2D_Simple(const uint32_t initw, const uint32_t inith, const float inita, const float inca); + int init(const uint32_t initw, const uint32_t inith, const float inita, const float inca); + void clear(); + int32_t getXPixels(); + float getX(); + void setX(const int32_t val); + void setX(const float val); + int32_t getYPixels(); + float getY(); + void setY(const int32_t val); + void setY(const float val); + void moveBy(const lash_game_coords_float_t addcoords); + void moveBy(float m, float r); + + int32_t getW(); + int32_t getH(); + void setResistance(float f); + float getResistance(); + + void setAcceleration(float a, float r); + void setAccelerationX(float newa); + void setAccelerationY(float newa); + void getAcceleration(float *a, float *r, int noresistance); + + float getAccelerationX(int noresistance); + float getAccelerationY(int noresistance); + float getAccelerationRadians(); + + void addAcceleration(float inca, float r); + void addAccelerationX(float inca); + void addAccelerationY(float inca); + + float getVel(); + void getVel(float *v, float *r); + float getVelRadians(); + float getVelX(); + float getVelY(); + + void addVel(float incv, float r); + void addVelX(float addx); + void addVelY(float addy); + + void setVelX(float newvx, int keepy); + void setVel(float v, float r); + void setVelY(float newvy, int keepx); + + int32_t getNextXPixels(); + float getNextX(); + int32_t getNextYPixels(); + float getNextY(); + void setMass(float newn); + float getMass(); + + void move(); + void moveX(); + void moveY(); + void accelerate(); + + void still(); + int walkLeft(int resetvelocity = 0); + int walkRight(int resetvelocity = 0); + void stop(); + + int jump(); + int isJumping(); + int isWalking(uint8_t state); + int isBouncing(); + void land(); + int bounce(); + void launch(); + void fall(); + + void finish(); + + void dumpState(char bitstring[]); + + void _old_land(); +}; + +#endif // LASH_BALLRUNNER_SPRITE_H_ diff --git a/c++/tests/fallbounceline.cpp b/c++/tests/fallbounceline.cpp @@ -0,0 +1,523 @@ +// ball fall and bounce against line + +#include "SDL.h" +#include "SDL_gfxPrimitives.h" +#include "../lash_game_sprite.h" +#include "liblash/lash_tree3.h" +#include "../../../liblash/lash_tree3_dump.h" +#include "../../lash_game_standard.h" +#include <stdio.h> +#include <math.h> +#include <stdlib.h> +#include <time.h> +#include <vector> + +#define SCREEN_WIDTH 1600 +#define SCREEN_HEIGHT 1000 +#define BPP 32 +#define BALL_LIMIT 12 +#define PIXELS_METER 100 +#define FPS 60 +#define LINE_WEIGHT 1 +#define BOUNCE 0.4 +#define BALL_MASS 2.0 + + +namespace lash_fallbounceline { + struct vertices { + int16_t x1; + int16_t y1; + int16_t x2; + int16_t y2; + }; + + struct ball { + //unsigned int index; + Lash_Sprite_2D_Simple *sprite; + unsigned int color; + }; + + class e_display : public std::exception { + virtual const char* what() const throw() { + return "Could not generate display!"; + } + } displayException; + + class e_collision : public std::exception { + virtual const char* what() const throw() { + return "Invalid collision data!"; + } + } collisionException; +}; + +void cursordata (uint8_t *data, uint8_t *mask) { + int i, j; + for (i=0; i<8; i++) { + for (j=0; j<8; j++) { + if (j >= 2 || j <= 6) { + *(data+j+(8*i)) = 0x01; + } + *(mask+j+(8*i)) = 0x01; + } + } +} + +int main(int argc, char *argv[]) { + + int i; + + //int test_warmup_count = 100; + + //struct timespec test_approx_time_begin, test_approx_time_end, test_isec_time_begin, test_isec_time_end; + //long test_approx_time_total, test_isec_time_total; + //int test_approx_count = 10000; + //int test_isec_count = 10000; + + int run = 1; + int pause = 0; + int step = 0; + //unsigned long frame_current_time = 0; + unsigned int frames_total = 0; + //unsigned int frame_lastmouse = 0; + float bounce; + lash_fallbounceline::ball *spawn; + unsigned short spawnx; + //float alignedxtoball, alignedytoball; + lash_game_coords_float_t ballcoll1, ballcoll2; + + float ball_radius; + float line1_rads, line2_rads; + lash_game_line_t line1, line2; + lash_game_coords_float_t line1_start, line2_start, line1_end, line2_end; + float line1_length, line2_length; + //lash_fallbounceline::vertices line1_v, line2_v; + + SDL_Surface *screen; + SDL_Event event; + SDL_Cursor *cursor; + + SDL_Rect screen_r; + //SDL_Rect ball_r; + + int16_t *line1_collision, *line2_collision; + + uint32_t screen_c; + uint32_t line1_c, line2_c; + uint32_t cursor_c; + //uint32_t line1border_c; + uint32_t line2border_c; + uint32_t borderactive_c, borderinactive_c; + uint8_t cursor_data[64], cursor_mask[64]; + + int mousex, mousey; + char debugstring[512]; + int coll; + + // vectors cannot be created with references + std::vector<struct lash_fallbounceline::ball> balls; + balls.resize(BALL_LIMIT); + std::vector<struct lash_fallbounceline::ball*> balls_free; + std::vector<struct lash_fallbounceline::ball*> balls_active; + + if (argc < 10) { + printf("Usage: %s ball_radius line1_m line1_c line1_x line1_l line2_m line2_c line2_x line2_l [bounce]\n", argv[0]); + return 1; + } + + ball_radius = atof(argv[1]); + + line1.m = atof(argv[2]); + line1.c = atof(argv[3]); + line1_start.x = atof(argv[4]); + line1_length = atof(argv[5]); + + line2.m = atof(argv[6]); + line2.c = atof(argv[7]); + line2_start.x = atof(argv[8]); + line2_length = atof(argv[9]); + + if (argv[10] != NULL) + bounce = atof(argv[10]); + else + bounce = BOUNCE; + + line1_rads = atan(line1.m / 1); + line2_rads = atan(line2.m / 1); + + line1_start.y = (line1.m * line1_start.x) + line1.c; + line2_start.y = (line2.m * line2_start.x) + line2.c; + + //line1_v.y1 = line1_start.y; + //line1_v.x1 = line1_start.x; + line1_end.y = line1_start.y + sin(line1_rads) * line1_length; + line1_end.x = line1_start.x + cos(line1_rads) * line1_length; + //line1_v.y2 = round(line1_end.y); + //line1_v.x2 = round(line1_end.x); + + //line2_v.y1 = line2_start.y; + //line2_v.x1 = line2_start.x; + line2_end.y = line2_start.y + sin(line2_rads) * line2_length; + line2_end.x = line2_start.x + cos(line2_rads) * line2_length; + //line2_v.y2 = round(line2_end.y); + //line2_v.x2 = round(line2_end.x); + + line1_collision = (int16_t*)malloc(sizeof(int16_t)*8); + line2_collision = (int16_t*)malloc(sizeof(int16_t)*8); + + if (line1_collision == NULL || line2_collision == NULL) { + return 1; + } else { + uint16_t modx, mody, startx, starty, endx, endy; + modx = cos(line1_rads) * ball_radius; + mody = sin(line1_rads) * ball_radius; + + startx = line1_start.x; + starty = line1_start.y; + endx = line1_end.x; + endy = line1_end.y; + + // top left + *line1_collision = startx - (modx + mody); + *(line1_collision+4) = starty - (mody - modx); + + // top right + *(line1_collision+1) = endx + (modx - mody); + *(line1_collision+5) = endy + (mody + modx); + + // bottom right + *(line1_collision+2) = endx + (modx + mody); + *(line1_collision+6) = endy + (mody - modx); + + // bottom left + *(line1_collision+3) = startx - (modx - mody); + *(line1_collision+7) = starty - (mody + modx); + + + modx = cos(line2_rads) * ball_radius; + mody = sin(line2_rads) * ball_radius; + startx = line2_start.x; + starty = line2_start.y; + endx = line2_end.x; + endy = line2_end.y; + + // top left + *line2_collision = startx - (modx + mody); + *(line2_collision+4) = starty - (mody - modx); + + // top right + *(line2_collision+1) = endx + (modx - mody); + *(line2_collision+5) = endy + (mody + modx); + + // bottom right + *(line2_collision+2) = endx + (modx + mody); + *(line2_collision+6) = endy + (mody - modx); + + // bottom left + *(line2_collision+3) = startx - (modx - mody); + *(line2_collision+7) = starty - (mody + modx); + + } + + srand(clock()); + + for (i = 0; i < BALL_LIMIT; i++) { + balls[i].sprite = new Lash_Sprite_2D_Simple((uint8_t)ball_radius * 2, (uint8_t)ball_radius * 2, 0.0, 0.0); + balls_free.push_back(&balls[i]); + } + + screen_c = 0xFF707070; + line1_c = 0xFF00AAFF; + line2_c = 0xFFAA00FF; + cursor_c = 0x00FF00FF; + borderinactive_c = 0xFFFFFF99; + borderactive_c = 0xFFFFFFFF; + //line1border_c = borderinactive_c; + line2border_c = borderinactive_c; + + screen_r.x = 0; + screen_r.y = 0; + screen_r.w = SCREEN_WIDTH; + screen_r.h = SCREEN_HEIGHT; + + SDL_Init(SDL_INIT_VIDEO); + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, BPP, SDL_HWSURFACE | SDL_DOUBLEBUF); + + if (screen == NULL) + throw lash_fallbounceline::displayException; + + cursordata(cursor_data, cursor_mask); + + cursor = SDL_CreateCursor(cursor_data, cursor_mask, 8, 8, 4, 0); + //SDL_SetCursor(cursor); + //SDL_ShowCursor(1); + + while (run) { + + //frame_current_time = SDL_GetTicks(); + + SDL_GetMouseState(&mousex, &mousey); + spawn = NULL; + + while (SDL_PollEvent(&event)) { + switch(event.type) { + case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_ESCAPE) + run = 0; + else if (event.key.keysym.sym == SDLK_p) + if (pause == 1) + pause = 0; + else + pause = 1; + else if (event.key.keysym.sym == SDLK_s) + step = 1; + break; + case SDL_MOUSEMOTION: + break; + + /// \todo after exhausting BALL_LIMIT it always picks the same ball object + case SDL_MOUSEBUTTONDOWN: + if (event.button.button == SDL_BUTTON_LEFT && pause == 0) { + if (balls_free.size() != 0 && spawn == NULL) { + spawnx = event.button.x; + balls_active.push_back(balls_free.back()); + balls_free.pop_back(); + //frame_lastmouse = frame_current_time; + spawn = balls_active.back(); + } + } + break; + } + } + + if (pause == 0 || step == 1) { + + if (spawn != NULL) { + spawn->sprite->clear(); + spawn->sprite->setX(spawnx); + spawn->sprite->setY(spawn->sprite->getH()); + spawn->sprite->setMass(BALL_MASS); + spawn->sprite->setAcceleration(((LASH_GAME_GRAVITY_EARTH* PIXELS_METER) / FPS )/ FPS, (3 * M_PI_2)); + spawn->color = rand() % (int)pow(2,24); + spawn->color <<= 8; + spawn->color |= 255; + } + + if (balls_active.size() > 0) { + // + // MOVEMENT + // + + + // erasing an element inside an iteration; new iterator must be returned instead of incrementing ... http://stackoverflow.com/questions/4645705/vector-erase-iterator + for (std::vector<struct lash_fallbounceline::ball*>::iterator it = balls_active.begin(); it != balls_active.end(); ) { + (*it)->sprite->move(); + (*it)->sprite->accelerate(); + if ((*it)->sprite->getY() > SCREEN_HEIGHT) { + balls_free.push_back((*it)); + it = balls_active.erase(it); + } else { + ++it; + } + } + + } // if balls_active.size() > 0 + + } // if pause == 0 + + + if (balls_active.size() > 0) { + + // + // COLLISION + // + + /// \todo move commented collision approximation code to separate file, maybe can be used later + // APPROXIMATION + /* + float ytoball, xtoball, distancetoball, alignedangletoball; + + for (i = 0; i < test_approx_count + test_warmup_count; i++) { + + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &test_approx_time_begin); + + coll = 0; + ytoball = balls_active[0]->sprite->getY() - line2_end.y; + xtoball = balls_active[0]->sprite->getX() - line2_end.x; + distancetoball = sqrt(pow(ytoball, 2) + pow(xtoball,2)); + //alignedangletoball = M_PI - line2_rads - fabs(atan2(ytoball, xtoball)); + alignedangletoball = atan(ytoball / xtoball) - line2_rads; + alignedxtoball = cos(alignedangletoball) * distancetoball; + alignedytoball = sin(alignedangletoball) * distancetoball; + if (alignedxtoball > -ball_radius && alignedxtoball - line2_length < ball_radius && abs(alignedytoball) < ball_radius) + coll = 1; + + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &test_approx_time_end); + + if (i >= test_warmup_count) + test_approx_time_total = test_approx_time_end.tv_nsec - test_approx_time_begin.tv_nsec; + + } // test approx timing + */ + + // INTERSECTION TEST + + for (i = 0; i < (int)balls_active.size(); i++) { + + char iseccollcount; + float linerads, line_x, line_y; + lash_game_coords_float_t ballcoords; + ballcoords.x = balls_active[i]->sprite->getX(); + ballcoords.y = balls_active[i]->sprite->getY(); + + coll = 0; + iseccollcount = lashCollisionCheckCircleLine(ballcoords, ball_radius, line2, &ballcoll1, &ballcoll2); + if (iseccollcount == 2) { + // check both sides! + //if ((ballcoll2.x > line2_start.x && ballcoll1.x < line2_start.x) || (ballcoll1.x < line2_end.x && ballcoll2.x > line2_end.x) || (ballcoll1.x > line2_start.x && ballcoll2.x < line2_end.x)) { + if (ballcoll2.x > line2_start.x && ballcoll1.x < line2_start.x) { + //linerads = line2_rads + M_PI_2; + linerads = atan((balls_active[i]->sprite->getY() - line2_start.y) / (balls_active[i]->sprite->getX() - line2_start.x)) + M_PI_2; + line_x = line2_start.x; + line_y = line2_start.y; + coll = -1; + } + else if (ballcoll1.x < line2_end.x && ballcoll2.x > line2_end.x) { + linerads = atan((balls_active[i]->sprite->getY() - line2_end.y) / (balls_active[i]->sprite->getX() - line2_end.x)) + M_PI_2; + line_x = line2_end.x; + line_y = line2_end.y; + coll = 1; + } + else if (ballcoll1.x > line2_start.x && ballcoll2.x < line2_end.x) { + linerads = line2_rads; + coll = 2; + } + } else if (iseccollcount == 1) { + linerads = line2_rads; + coll = 1; + } + + if (coll == 0) { + iseccollcount = lashCollisionCheckCircleLine(ballcoords, ball_radius, line1, &ballcoll1, &ballcoll2); + if (iseccollcount == 2) { + // check both sides! + if (ballcoll2.x > line1_start.x && ballcoll1.x < line1_start.x) { + //linerads = line1_rads + M_PI_2; + linerads = atan((balls_active[i]->sprite->getY() - line1_start.y) / (balls_active[i]->sprite->getX() - line1_start.x)) + M_PI_2; + line_x = line1_start.x; + line_y = line1_start.y; + coll = -1; + } else if (ballcoll1.x < line1_end.x && ballcoll2.x > line1_end.x) { + linerads = atan((balls_active[i]->sprite->getY() - line1_end.y) / (balls_active[i]->sprite->getX() - line1_end.x)) + M_PI_2; + line_x = line1_end.x; + line_y = line1_end.y; + coll = 1; + } else if (ballcoll1.x > line1_start.x && ballcoll2.x < line1_end.x) { + linerads = line1_rads; + coll = 2; + } + } else if (iseccollcount == 1) { + linerads = line1_rads; + coll = 1; + } + } + + if (coll && (pause == 0 || step == 1)) { + float ballvel, ballrad, oldrad, balloverlap, balladjust; + //lash_game_coords_float_t ballbouncecorrection; + balls_active[i]->sprite->getVel(&ballvel, &ballrad); + oldrad = ballrad; + + // check for later implementations that we are on the right side of the horizontal, useless use of resources to convert back and forth + // oldrad = ballrad; + //ballrad = -ballrad; + /* + + ballrad = -ballrad; + */ + // correct for the movement past the surface + // (finds the difference (distance) from the circle centre to the perpendicular intersection of the surface line, and subtracts that from radius) + + if (coll == 2) + balloverlap = ball_radius - sqrt(pow(balls_active[i]->sprite->getX() - (ballcoll1.x + ((ballcoll2.x - ballcoll1.x) / 2)), 2) + pow(balls_active[i]->sprite->getY() - (ballcoll1.y + ((ballcoll2.y - ballcoll1.y) / 2)), 2)); + else if (coll == 1) + balloverlap = ball_radius - sqrt(pow(balls_active[i]->sprite->getX() - line_x, 2) + pow(balls_active[i]->sprite->getY() - line_y, 2)); + else if (coll == -1) + balloverlap = ball_radius - sqrt(pow(balls_active[i]->sprite->getX() - line_x, 2) + pow(balls_active[i]->sprite->getY() - line_y, 2)); + else // shouldnt be here + throw lash_fallbounceline::collisionException; + + + if ((lashGetQuadrant(oldrad) - lashGetQuadrant(-linerads)) % 2 != 0) + balladjust = balloverlap / fabs(cos(M_PI_2 - lashNormalizeQuadrantRadians(ballrad) - lashNormalizeQuadrantRadians(linerads))); + else + balladjust = balloverlap / fabs(cos(lashNormalizeQuadrantRadians(ballrad) + lashNormalizeQuadrantRadians(linerads))); + + balls_active[i]->sprite->moveBy(balladjust, ballrad + M_PI); + + lashCollisionSurfaceDeflectSimple(&ballvel, &ballrad, -linerads, bounce); + + // these are attempts of manually simulating the velocity of the ball along the surface of the force preserved from the collision WITHOUT bounce. + // None of the attempts have been successful. The routine seem to work without, but is less accurate + //balls_active[i]->sprite->moveBy(balloverlap / tan(linerads), -linerads); + //balls_active[i]->sprite->moveBy(balloverlap / cos(linerads), -linerads); + + // move the bounce ratio part of the split velocity perp away from the slope + balls_active[i]->sprite->moveBy(balloverlap * bounce, ballrad); + balls_active[i]->sprite->setVel(ballvel, ballrad); + } + + } // for balls_active + + } // if balls_active[0].size() > 0 + + + // + // RENDERING + // + + if (balls_active.size() > 0) + sprintf(debugstring, "Mouse X %d | Ball 1 X %f Y %f V %f R %f", mousex, balls_active[0]->sprite->getX(), balls_active[0]->sprite->getY(), balls_active[0]->sprite->getVel(), balls_active[0]->sprite->getVelRadians()); + else + sprintf(debugstring, "Mouse X %d", mousex); + + SDL_FillRect(screen, &screen_r, screen_c); + + // cursor + thickLineColor(screen, mousex, 0, mousex, 16, 4, cursor_c); + + // lines + thickLineColor(screen, line1_start.x, line1_start.y, line1_end.x, line1_end.y, LINE_WEIGHT, line1_c); + thickLineColor(screen, line2_start.x, line2_start.y, line2_end.x, line2_end.y, LINE_WEIGHT, line2_c); + + // balls + // note the (*it) dereference, struggled with this, but found solution here: http://stackoverflow.com/questions/10325774/iterator-with-vector-pointer + for (std::vector<struct lash_fallbounceline::ball*>::iterator it = balls_active.begin(); it != balls_active.end(); ++it) { + filledCircleColor(screen, (*it)->sprite->getX(), (*it)->sprite->getY(), ball_radius, (*it)->color); + } + + // debug + stringColor(screen, 10, SCREEN_HEIGHT - 15, debugstring, 0x00000099); + if (coll == 1 && line2border_c == borderinactive_c) + line2border_c = borderactive_c; + else if (coll == 0 && line2border_c == borderactive_c) + line2border_c = borderinactive_c; + + //aapolygonColor(screen, line2_collision, (line2_collision+4), 4, line2border_c); + //aapolygonColor(screen, line1_collision, (line1_collision+4), 4, borderinactive_c); + + SDL_Flip(screen); + SDL_Delay(1000 / FPS); + + frames_total++; + step = 0; + } + + SDL_FreeSurface(screen); + SDL_FreeCursor(cursor); + SDL_Quit(); + free(line1_collision); + free(line2_collision); + + return 0; +} + diff --git a/c++/tests/fallbounceline.dat b/c++/tests/fallbounceline.dat @@ -0,0 +1,3 @@ +50.0 -1.0 1200.0 500.0 570.0 0.5 100.0 200.0 450.0 + +50.0 0.5 250.0 150.0 450.0 0.5 100.0 300.0 450.0 diff --git a/c++/tests/iswalking.cpp b/c++/tests/iswalking.cpp @@ -0,0 +1,20 @@ +// iswalking check + +#include "../lash_game_sprite.h" +#include <stdio.h> + +int main() { + Lash_Sprite_2D_Simple *s = new Lash_Sprite_2D_Simple(100, 100, 0.f, 0.f); + printf("Init iswalking: %d\n", s->isWalking(0)); + s->walkRight(); + printf("After right iswalking: %d\n", s->isWalking(0)); + printf("After right iswalking(right): %d\n", s->isWalking(LASH_GAME_SPRITE_SIMPLE_STATE_RIGHT)); + s->walkLeft(); + printf("After left iswalking: %d\n", s->isWalking(0)); + printf("After left iswalking(right): %d\n", s->isWalking(LASH_GAME_SPRITE_SIMPLE_STATE_RIGHT)); + printf("After left iswalking(left): %d\n", s->isWalking(LASH_GAME_SPRITE_SIMPLE_STATE_LEFT)); + s->stop(); + printf("After stop iswalking: %d\n", s->isWalking(0)); + return 0; + +} diff --git a/c++/tests/slopeaccel.cpp b/c++/tests/slopeaccel.cpp @@ -0,0 +1,234 @@ +// Physics slope experiment with lash_game_sprite + +#include "SDL.h" +#include "SDL_gfxPrimitives.h" +#include "../lash_game_sprite.h" +#include <math.h> +#include <stdio.h> + +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 600 +#define BALL_RADIUS 30 +#define BPP 32 +#define FPS 60 +#define GRAVITY 9.8 +#define PIXELS_METER 100 + +/** + * \todo upon landing ball falls below ground and ends up in right bottom corner + */ + +int main(int argc, char *argv[]) { + + int i; + + unsigned long frametime; + unsigned long lastframetime; + float minframetime = 1000 / (float)FPS; + int run = 1; + int state = 0; + + Lash_Sprite_2D_Simple *sprite; + + SDL_Event event; + SDL_Surface *screen; + + SDL_Rect screen_r; + //SDL_Rect ball_r; + + uint32_t screen_c; + //uint32_t ball_c; + //uint32_t slope_c; + + //uint32_t ball_slope_offset_y; + float p_ball_force_net; + float p_ball_force_norm; + float slope_friction; + + float slope_angle; + + uint8_t slope_v_size = 6; + Sint16 *slope_v_x; + Sint16 *slope_v_y; + + float ballxinit; + float ballyinit; + + char debugstring[255]; + unsigned int framesrun; + unsigned long timestart; + float *debugframevels; + + if (argc < 3) { + printf("Usage: %s slope_angle_in_degrees ball_mass_in_grammes slope_friction_coeffcient\n", argv[0]); + return 1; + } + + + sprite = new Lash_Sprite_2D_Simple(BALL_RADIUS * 2, BALL_RADIUS * 2, 0.f, 0.f); + sprite->setMass(atof(argv[2])); + + //radians + slope_angle = (atof(argv[1]) * M_PI) / 180; + slope_friction = atof(argv[3]); + if (!slope_friction) + slope_friction = 0.f; + + SDL_Init(SDL_INIT_VIDEO); + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, BPP, SDL_HWSURFACE|SDL_DOUBLEBUF); + + if (screen == NULL) + return 1; + + slope_v_x = (Sint16*)malloc(sizeof(Sint16)*slope_v_size); + slope_v_y = (Sint16*)malloc(sizeof(Sint16)*slope_v_size); + + if (slope_v_x == NULL || slope_v_y == NULL) + return 1; + + debugframevels = (float*)malloc(sizeof(float) * 10000); // should be ample + + screen_r.x = 0; + screen_r.y = 0; + screen_r.w = SCREEN_WIDTH; + screen_r.h = SCREEN_HEIGHT; + + //ball_r.x = 0; + //ball_r.y = 0; + //ball_r.w = BALL_RADIUS * 2; + //ball_r.h = BALL_RADIUS * 2; + + screen_c = SDL_MapRGBA(screen->format, 255, 255, 255, 255); + //slope_c = SDL_MapRGBA(screen->format, 0, 0, 255, 255); + //ball_c = SDL_MapRGBA(screen->format, 255, 0, 0, 255); + + *slope_v_y = SCREEN_HEIGHT; + *(slope_v_y + 1) = (SCREEN_HEIGHT / 2) - ((SCREEN_WIDTH / 4) * tan(slope_angle)); + *(slope_v_y + 2) = SCREEN_HEIGHT / 2; + *(slope_v_y + 3) = SCREEN_HEIGHT / 2; + *(slope_v_y + 4) = (SCREEN_HEIGHT / 2) - ((SCREEN_WIDTH / 4) * tan(slope_angle)); + *(slope_v_y + 5) = SCREEN_HEIGHT; + + *slope_v_x = 0; + *(slope_v_x + 1) = 0; + *(slope_v_x + 2) = SCREEN_WIDTH / 4; + *(slope_v_x + 3) = 3 * (SCREEN_WIDTH / 4); + *(slope_v_x + 4) = SCREEN_WIDTH; + *(slope_v_x + 5) = SCREEN_WIDTH; + + ballxinit = BALL_RADIUS; + ballyinit = (BALL_RADIUS / cos(slope_angle)); + sprite->setY((int)((tan(slope_angle) * BALL_RADIUS) + *(slope_v_y + 1) - ballyinit)); + sprite->setX((int)ballxinit); + + p_ball_force_net = sin(slope_angle) * (GRAVITY * sprite->getMass()); + p_ball_force_norm = cos(slope_angle) * (GRAVITY * sprite->getMass()); + if (p_ball_force_net < 0.f) + p_ball_force_net = 0.f; + + // divide by FPS twice, as it's m/s² + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, -slope_angle); + // resistance is friction translated to m/s + sprite->setResistance(((p_ball_force_norm / sprite->getMass()) * slope_friction) / FPS); + + float tmpav, tmpar; + sprite->getAcceleration(&tmpav, &tmpar, 0); + printf("FPS: %d\nPixels per meter: %d\nSprite: x %.1fpx, y %.1fpx, mass %.2fkg\nSlope: angle %f, resistance %fm/s, distance %f\nObject force %.2fN, accel: %f m/s/s | %f px/frame, radians %f\n", FPS, PIXELS_METER, sprite->getX(), sprite->getY(), sprite->getMass(), slope_angle, sprite->getResistance(), SCREEN_WIDTH / cos(slope_angle), p_ball_force_net, ((float)p_ball_force_net / sprite->getMass()), tmpav * FPS, tmpar); + + SDL_WM_SetCaption("Slope Physics Test", 0); + + while (run) { + + frametime = SDL_GetTicks(); + + while (SDL_PollEvent(&event)) { + switch(event.type) { + case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_ESCAPE) { + run = 0; + } else if (event.key.keysym.sym == SDLK_SPACE) { + sprite->walkRight(); + framesrun = 0; + timestart = frametime; + } else if (event.key.keysym.sym == SDLK_r) { + sprite->stop(); + sprite->setVel(0.f, 0.f); + sprite->setY((int)((tan(slope_angle) * BALL_RADIUS) + *(slope_v_y + 1) - ballyinit)); + sprite->setX((int)ballxinit); + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, -slope_angle); + state = 0; + } + + break; + } + + } + + if (sprite->isWalking(0)) { + + sprite->move(); + + // enter midfield + if (sprite->getX() > SCREEN_WIDTH / 4 && sprite->getX() < 3 * (SCREEN_WIDTH / 4) && state != 1) { + sprite->setAcceleration(0.f, sprite->getAccelerationRadians()); + sprite->addVel(sprite->getVelY(), M_PI_2); + sprite->setY((SCREEN_HEIGHT / 2) - BALL_RADIUS); + state = 1; + // enter right slope + } else if (sprite->getX() > 3 * (SCREEN_WIDTH / 4) && state != 2) { + sprite->setVel(sprite->getVel(), slope_angle); + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, slope_angle - M_PI); + sprite->setY(sprite->getY() + BALL_RADIUS - ballyinit); + state = 2; + // enter left slope (not from beginning) + } else if (sprite->getX() < SCREEN_WIDTH / 4 && state != 0) { + sprite->setVel(sprite->getVel(), -slope_angle - M_PI); + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, -slope_angle); + sprite->setY(sprite->getY() + BALL_RADIUS - ballyinit); + state = 0; + } + + sprite->accelerate(); + + if (sprite->getY() >= SCREEN_HEIGHT - BALL_RADIUS || sprite->getX() >= SCREEN_WIDTH - BALL_RADIUS || sprite->getVel() == 0.f) { + if (sprite->getY() >= SCREEN_HEIGHT - BALL_RADIUS || sprite->getX() >= SCREEN_WIDTH - BALL_RADIUS) { + sprite->setX(SCREEN_WIDTH - BALL_RADIUS); + } + sprite->stop(); + printf("End velocity: %f px/frame (%f m/s) after %.2f secs, %d frames. \n---\nVels:\n", *(debugframevels + framesrun - 1), ((*(debugframevels + framesrun - 1) / PIXELS_METER) * FPS), (frametime - timestart) / (float)1000, framesrun); + + if (debugframevels != NULL) { + for (i = 0; i < (int)framesrun; i++) { + printf("Frame %d: %f\n", i, *(debugframevels+i)); + } + } + } + + if (debugframevels != NULL) + *(debugframevels + framesrun) = sprite->getVel(); + framesrun++; + + } + + sprintf(debugstring, "Frametime %lu", frametime - lastframetime); + SDL_FillRect(screen, &screen_r, screen_c); + filledPolygonColor(screen, slope_v_x, slope_v_y, slope_v_size, 0x0000ffff); + filledCircleColor(screen, sprite->getXPixels(), sprite->getYPixels(), BALL_RADIUS, 0xff0000ff); + stringColor(screen, 10, SCREEN_HEIGHT - 15, debugstring, 0xffffff99); + SDL_Flip(screen); + + lastframetime = frametime; + + //if (lastframetime - frametime < minframetime) + //SDL_Delay (minframetime - (SDL_GetTicks () - frametime)); + SDL_Delay(minframetime); + + + } + + delete(sprite); + SDL_FreeSurface(screen); + SDL_Quit(); + + return 0; +} diff --git a/c++/tests/slopecollide.cpp b/c++/tests/slopecollide.cpp @@ -0,0 +1,333 @@ +// Physics slope experiment with lash_game_sprite + +#include "SDL.h" +#include "SDL_gfxPrimitives.h" +#include "../lash_game_sprite.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 600 +#define BALL_RADIUS 30 +#define BPP 32 +#define FPS 60 +#define GRAVITY 9.8 +#define PIXELS_METER 100 +#define COLLISION_CUTOFF 0.3 +#define BOUNCE 0.25 + +/// \todo bounce was never implemented in this test + +int applyBounce() { + + return 0; +} + + + +int main(int argc, char *argv[]) { + + int i; + + unsigned long frametime; + unsigned long lastframetime; + unsigned long startframetime; + float minframetime = 1000 / (float)FPS; + int run = 1; + int state = 0; + + Lash_Sprite_2D_Simple *sprite; + + SDL_Event event; + SDL_Surface *screen; + + SDL_Rect screen_r; + SDL_Rect ball_r; + + uint32_t screen_c; + uint32_t ball_c; + uint32_t slope_c; + + uint32_t ball_slope_offset_y; + float p_ball_force_net; + float p_ball_force_norm; + float slope_friction; + + float slope_angle_1, slope_angle_2, slope_gap; + float momentum_spill; + float bounce_vel; + + uint8_t slope_v_size = 5; + Sint16 *slope_v_x; + Sint16 *slope_v_y; + + float ballxinit; + float ballyinit_1, ballyinit_2; + float monitoroldv, monitorv, monitorrv, monitora, monitorra; + + char debugstring[255]; + unsigned int framesrun; + unsigned long timestart; + unsigned long monitorframesturn; + + float *debugframevels; + float *debugframevelrads; + + if (argc < 4) { + printf("Usage: %s slope_angle_left_in_degrees slope_angle_right_in_degrees ball_mass_in_grammes slope_friction_coeffcient\n", argv[0]); + return 1; + } + + + sprite = new Lash_Sprite_2D_Simple(BALL_RADIUS * 2, BALL_RADIUS * 2, 0.f, 0.f); + sprite->setMass(atof(argv[3])); + + //radians + slope_angle_1 = (atof(argv[1]) * M_PI) / 180; + slope_angle_2 = (atof(argv[2]) * M_PI) / 180; + slope_gap = M_PI - slope_angle_1 - slope_angle_2; + + slope_friction = atof(argv[4]); + if (!slope_friction) + slope_friction = 0.f; + + SDL_Init(SDL_INIT_VIDEO); + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, BPP, SDL_HWSURFACE|SDL_DOUBLEBUF); + + if (screen == NULL) + return 1; + + slope_v_x = (Sint16*)malloc(sizeof(Sint16)*slope_v_size); + slope_v_y = (Sint16*)malloc(sizeof(Sint16)*slope_v_size); + + if (slope_v_x == NULL || slope_v_y == NULL) + return 1; + + debugframevels = (float*)malloc(sizeof(float) * 10000); // should be ample + debugframevelrads = (float*)malloc(sizeof(float) * 10000); + + monitorframesturn = 0; + + screen_r.x = 0; + screen_r.y = 0; + screen_r.w = SCREEN_WIDTH; + screen_r.h = SCREEN_HEIGHT; + + ball_r.x = 0; + ball_r.y = 0; + ball_r.w = BALL_RADIUS * 2; + ball_r.h = BALL_RADIUS * 2; + + screen_c = SDL_MapRGBA(screen->format, 255, 255, 255, 255); + slope_c = SDL_MapRGBA(screen->format, 0, 0, 255, 255); + ball_c = SDL_MapRGBA(screen->format, 255, 0, 0, 255); + + *slope_v_y = SCREEN_HEIGHT; + *(slope_v_y + 1) = (SCREEN_HEIGHT / 2) - ((SCREEN_WIDTH / 2) * tan(slope_angle_1)); + *(slope_v_y + 2) = SCREEN_HEIGHT / 2; + *(slope_v_y + 3) = (SCREEN_HEIGHT / 2) - ((SCREEN_WIDTH / 2) * tan(slope_angle_2)); + *(slope_v_y + 4) = SCREEN_HEIGHT; + + *slope_v_x = 0; + *(slope_v_x + 1) = 0; + *(slope_v_x + 2) = SCREEN_WIDTH / 2; + *(slope_v_x + 3) = SCREEN_WIDTH; + *(slope_v_x + 4) = SCREEN_WIDTH; + + ballxinit = BALL_RADIUS; + ballyinit_1 = (BALL_RADIUS / cos(slope_angle_1)); + ballyinit_2 = (BALL_RADIUS / cos(slope_angle_2)); + sprite->setY((int)((tan(slope_angle_1) * BALL_RADIUS) + *(slope_v_y + 1) - ballyinit_1)); + sprite->setX((int)ballxinit); + + p_ball_force_net = sin(slope_angle_1) * (GRAVITY * sprite->getMass()); + p_ball_force_norm = cos(slope_angle_1) * (GRAVITY * sprite->getMass()); + if (p_ball_force_net < 0.f) + p_ball_force_net = 0.f; + + // divide by FPS twice, as it's m/s² + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, -slope_angle_1); + // resistance is friction translated to m/s + sprite->setResistance(((p_ball_force_norm / sprite->getMass()) * slope_friction) / FPS); + + float tmpav, tmpar; + sprite->getAcceleration(&tmpav, &tmpar, 0); + printf("# FPS: %d\n# Pixels per meter: %d\n# Sprite: x %.1fpx, y %.1fpx, mass %.2fkg\n# Slope left: angle %f, resistance %fm/s, distance %f\n# Slope right: angle %f, distance %f\n# Object force %.2fN, accel: %f m/s/s | %f px/frame, radians %f\n", FPS, PIXELS_METER, sprite->getX(), sprite->getY(), sprite->getMass(), slope_angle_1, sprite->getResistance(), (SCREEN_WIDTH / 2) / cos(slope_angle_1), slope_angle_2, (SCREEN_WIDTH / 2) / cos(slope_angle_2), p_ball_force_net, ((float)p_ball_force_net / sprite->getMass()), tmpav * FPS, tmpar); + + SDL_WM_SetCaption("Slope Physics Test", 0); + + while (run) { + + frametime = SDL_GetTicks(); + + while (SDL_PollEvent(&event)) { + switch(event.type) { + case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_ESCAPE) { + run = 0; + } else if (event.key.keysym.sym == SDLK_SPACE) { + sprite->walkRight(); + framesrun = 0; + timestart = frametime; + } else if (event.key.keysym.sym == SDLK_r) { + sprite->stop(); + sprite->setVel(0.f, 0.f); + sprite->setY((int)((tan(slope_angle_1) * BALL_RADIUS) + *(slope_v_y + 1) - ballyinit_1)); + sprite->setX((int)ballxinit); + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, -slope_angle_1); + state = 0; + } else if (event.key.keysym.sym == SDLK_s) { + state = 2; + } + break; + } + + } + + if (sprite->isWalking(0)) { + + sprite->move(); + sprite->accelerate(); + + if (state != 2) { + float newaccelangle; + float newvelangle; + float newymod; + const char *directionstring = "ltr\0"; + int newstate; + int newdirection = 0; + + // check if we're to land + if (sprite->isBouncing()) { + if (state == 1) { + newymod = ballyinit_1 - ballyinit_2; + newvelangle = slope_angle_2; + } + else { + newymod = ballyinit_2 - ballyinit_1; + newvelangle = -slope_angle_1 + M_PI; + } + if (ball->getY() <= tan(newvelangle) * abs(ball->getX() - SCREEN_WIDTH / 2) - newymod) { + ball->finish(); + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, newaccelangle); + sprite->setVel(); + } + } + + // enter right slope + if (sprite->getX() > SCREEN_WIDTH / 2 && state != 1) { + + newaccelangle = slope_angle_2 - M_PI; + newvelangle = slope_angle_2; + newymod = ballyinit_1 - ballyinit_2; + directionstring = "ltr\0"; + newstate = 1; + newdirection = 1; + + // enter left slope (from right slope) + } else if (sprite->getX() < SCREEN_WIDTH / 2 && state != 0) { + + newaccelangle = -slope_angle_1; + newvelangle = -slope_angle_1 - M_PI; + newymod = ballyinit_2 - ballyinit_1; + directionstring = "rtl\0"; + newstate = 0; + newdirection = 1; + + } + + if (newdirection) { + momentum_spill = sprite->getVel() * sin(slope_gap); + monitoroldv = monitorv; + sprite->getVel(&monitorv, &monitorrv); + sprite->getAcceleration(&monitora, &monitorra, 0); + sprite->setVel(sprite->getVel() - momentum_spill, newvelangle); + + if (sprite->getVel() < COLLISION_CUTOFF - (COLLISION_CUTOFF * slope_friction)) { + sprite->stop(); + } else { + + bounce_vel = momentum_spill * BOUNCE; + if (applyBounce(sprite, momentum_spill, monitoroldv)) { + + } else { + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, newaccelangle); + } + + if (bounce_vel * monitoroldv > 1.0) { + sprite->bounce(); + sprite->addVel(bounce_vel, monitorrv + M_PI); + sprite->setAcceleration(((GRAVITY * PIXELS_METER) / FPS) / FPS, 3 * (M_PI_2)); + } else { + + } + + } + + printf("# %s spill %f from vel %f (%f post-accel) new vel %f a %f (%f at %d frames)\n", directionstring, momentum_spill, monitoroldv, monitorv, sprite->getVel(), monitora, monitorra, framesrun); + + sprite->setY(sprite->getY() + newymod); + monitorframesturn = framesrun; + state = newstate; + } + } // if state != 2 + + + // if screen boundaries are hit + if (sprite->getY() >= SCREEN_HEIGHT - BALL_RADIUS || sprite->getX() >= SCREEN_WIDTH - BALL_RADIUS || sprite->getVel() == 0.f) { + if (sprite->getY() >= SCREEN_HEIGHT - BALL_RADIUS || sprite->getX() >= SCREEN_WIDTH - BALL_RADIUS) { + sprite->setX(SCREEN_WIDTH - BALL_RADIUS); + } + sprite->stop(); + + } + + if (debugframevels != NULL) { + sprite->getVel(&tmpav, &tmpar); + *(debugframevels + framesrun) = tmpav; + *(debugframevelrads + framesrun) = tmpar; + } + + // if we're done + if (!sprite->isWalking(0) || state == 2) { + if (state == 2) + printf("# ABORTED!\n"); + printf("# End velocity: %f px/frame (%f m/s) after %.2f secs, %d frames\n", *(debugframevels + framesrun - 1), ((*(debugframevels + framesrun - 1) / PIXELS_METER) * FPS), (frametime - timestart) / (float)1000, framesrun); + + sprite->stop(); + + if (debugframevels != NULL) { + for (i = 0; i <= framesrun; i++) { + //printf("Frame %d: %f @ %f\n", i, *(debugframevels+i), (*(debugframevelrads+i) / M_PI) * 180); + printf("%d\t%f\n", i, *(debugframevels+i), (*(debugframevelrads+i) / M_PI) * 180); + } + } + } + + framesrun++; + + } + + sprintf(debugstring, "Frametime %lu", frametime - lastframetime); + SDL_FillRect(screen, &screen_r, screen_c); + filledPolygonColor(screen, slope_v_x, slope_v_y, slope_v_size, 0x0000ffff); + filledCircleColor(screen, sprite->getXPixels(), sprite->getYPixels(), BALL_RADIUS, 0xff0000ff); + stringColor(screen, 10, SCREEN_HEIGHT - 15, debugstring, 0xffffff99); + SDL_Flip(screen); + + lastframetime = frametime; + + //if (lastframetime - frametime < minframetime) + //SDL_Delay (minframetime - (SDL_GetTicks () - frametime)); + SDL_Delay(minframetime); + + + } + + delete(sprite); + SDL_FreeSurface(screen); + SDL_Quit(); + + return 0; +} diff --git a/c++/tests/slopejump.cpp b/c++/tests/slopejump.cpp @@ -0,0 +1,237 @@ +// Physics slope experiment with lash_game_sprite + +#include "SDL.h" +#include "SDL_gfxPrimitives.h" +#include "../lash_game_sprite.h" +#include <math.h> +#include <stdio.h> + +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 600 +#define BALL_RADIUS 30 +#define BPP 32 +#define FPS 60 +#define GRAVITY 9.8 +#define PIXELS_METER 100 + +int main(int argc, char *argv[]) { + + int i; + + unsigned long frametime; + unsigned long lastframetime; + float minframetime = 1000 / (float)FPS; + int run = 1; + int state = 0; + + Lash_Sprite_2D_Simple *sprite; + + SDL_Event event; + SDL_Surface *screen; + + SDL_Rect screen_r; + //SDL_Rect ball_r; + + uint32_t screen_c; + //uint32_t ball_c; + //uint32_t slope_c; + + //uint32_t ball_slope_offset_y; + float p_ball_force_net; + float p_ball_force_norm; + float slope_friction; + + float slope_angle; + + uint8_t slope_v_size = 7; + Sint16 *slope_v_x; + Sint16 *slope_v_y; + + float ballxinit; + float ballyinit; + + float groundy; + float jumpwidth; + + char debugstring[255]; + unsigned int framesrun; + unsigned long timestart; + float *debugframevels; + + if (argc < 3) { + printf("Usage: %s slope_angle_in_degrees ball_mass_in_grammes slope_friction_coeffcient\n", argv[0]); + return 1; + } + + + sprite = new Lash_Sprite_2D_Simple(BALL_RADIUS * 2, BALL_RADIUS * 2, 0.f, 0.f); + sprite->setMass(atof(argv[2])); + + //radians + slope_angle = (atof(argv[1]) * M_PI) / 180; + slope_friction = atof(argv[3]); + if (!slope_friction) + slope_friction = 0.f; + + SDL_Init(SDL_INIT_VIDEO); + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, BPP, SDL_HWSURFACE|SDL_DOUBLEBUF); + + if (screen == NULL) + return 1; + + slope_v_x = (Sint16*)malloc(sizeof(Sint16)*slope_v_size); + slope_v_y = (Sint16*)malloc(sizeof(Sint16)*slope_v_size); + + if (slope_v_x == NULL || slope_v_y == NULL) + return 1; + + debugframevels = (float*)malloc(sizeof(float) * 10000); // should be ample + + screen_r.x = 0; + screen_r.y = 0; + screen_r.w = SCREEN_WIDTH; + screen_r.h = SCREEN_HEIGHT; + + //ball_r.x = 0; + //ball_r.y = 0; + //ball_r.w = BALL_RADIUS * 2; + //ball_r.h = BALL_RADIUS * 2; + + screen_c = SDL_MapRGBA(screen->format, 255, 255, 255, 255); + //slope_c = SDL_MapRGBA(screen->format, 0, 0, 255, 255); + //ball_c = SDL_MapRGBA(screen->format, 255, 0, 0, 255); + + groundy = SCREEN_HEIGHT * 0.75; + jumpwidth = SCREEN_WIDTH / 12.f; + + *slope_v_y = SCREEN_HEIGHT; + *(slope_v_y + 1) = (SCREEN_HEIGHT / 2) - ((SCREEN_WIDTH / 4) * tan(slope_angle)); + *(slope_v_y + 2) = SCREEN_HEIGHT / 2; + *(slope_v_y + 3) = (SCREEN_HEIGHT / 2) - (jumpwidth * tan(slope_angle)); + *(slope_v_y + 4) = groundy; + *(slope_v_y + 5) = groundy; + *(slope_v_y + 6) = SCREEN_HEIGHT; + + *slope_v_x = 0; + *(slope_v_x + 1) = 0; + *(slope_v_x + 2) = SCREEN_WIDTH / 4; + *(slope_v_x + 3) = (SCREEN_WIDTH / 4) + jumpwidth; + *(slope_v_x + 4) = (SCREEN_WIDTH / 4) + jumpwidth; + *(slope_v_x + 5) = SCREEN_WIDTH; + *(slope_v_x + 6) = SCREEN_WIDTH; + + ballxinit = BALL_RADIUS; + ballyinit = (BALL_RADIUS / cos(slope_angle)); + sprite->setY((int)((tan(slope_angle) * BALL_RADIUS) + *(slope_v_y + 1) - ballyinit)); + sprite->setX((int)ballxinit); + + p_ball_force_net = sin(slope_angle) * (GRAVITY * sprite->getMass()); + p_ball_force_norm = cos(slope_angle) * (GRAVITY * sprite->getMass()); + if (p_ball_force_net < 0.f) + p_ball_force_net = 0.f; + + // divide by FPS twice, as it's m/s² + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, -slope_angle); + // resistance is friction translated to m/s + sprite->setResistance(((p_ball_force_norm / sprite->getMass()) * slope_friction) / FPS); + + float tmpav, tmpar; + sprite->getAcceleration(&tmpav, &tmpar, 0); + printf("FPS: %d\nPixels per meter: %d\nSprite: x %.1fpx, y %.1fpx, mass %.2fkg\nSlope: angle %f, resistance %fm/s, distance %f\nObject force %.2fN, accel: %f m/s/s | %f px/frame, radians %f\n", FPS, PIXELS_METER, sprite->getX(), sprite->getY(), sprite->getMass(), slope_angle, sprite->getResistance(), SCREEN_WIDTH / cos(slope_angle), p_ball_force_net, ((float)p_ball_force_net / sprite->getMass()), tmpav * FPS, tmpar); + + SDL_WM_SetCaption("Slope Physics Test", 0); + + while (run) { + + frametime = SDL_GetTicks(); + + while (SDL_PollEvent(&event)) { + switch(event.type) { + case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_ESCAPE) { + run = 0; + } else if (event.key.keysym.sym == SDLK_SPACE) { + sprite->walkRight(); + framesrun = 0; + timestart = frametime; + } else if (event.key.keysym.sym == SDLK_r) { + sprite->stop(); + sprite->setVel(0.f, 0.f); + sprite->setY((int)((tan(slope_angle) * BALL_RADIUS) + *(slope_v_y + 1) - ballyinit)); + sprite->setX((int)ballxinit); + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, -slope_angle); + state = 0; + } + + break; + } + + } + + if (sprite->isWalking(0)) { + + sprite->move(); + + // enter jump + if (sprite->getX() > SCREEN_WIDTH / 4 && state < 1) { + sprite->setVel(sprite->getVel(), slope_angle); + sprite->setAcceleration((((p_ball_force_net / sprite->getMass()) * PIXELS_METER) / FPS) / FPS, slope_angle - M_PI); + state = 1; + } + else if (sprite->getX() > (SCREEN_WIDTH / 4) + jumpwidth && state < 2) { + sprite->setAcceleration(((GRAVITY * PIXELS_METER) / FPS )/ FPS, 3 * (M_PI_2)); + sprite->setResistance(0.f); + state = 2; + // land + } else if (sprite->getX() > SCREEN_WIDTH * (5 / 12.f) && sprite->getY() >= groundy && state < 3) { + sprite->addVel(sprite->getVelY(), M_PI_2); + sprite->setAcceleration(0.f, 0.f); + sprite->setResistance(((p_ball_force_norm / sprite->getMass()) * slope_friction) / FPS); + sprite->setY(groundy - BALL_RADIUS); + state = 3; + } + + sprite->accelerate(); + + if (sprite->getY() >= SCREEN_HEIGHT - BALL_RADIUS || sprite->getX() >= SCREEN_WIDTH - BALL_RADIUS || sprite->getVel() == 0.f) { + if (sprite->getY() >= SCREEN_HEIGHT - BALL_RADIUS || sprite->getX() >= SCREEN_WIDTH - BALL_RADIUS) { + sprite->setX(SCREEN_WIDTH - BALL_RADIUS); + } + sprite->stop(); + printf("End velocity: %f px/frame (%f m/s) after %.2f secs, %d frames. \n---\nVels:\n", *(debugframevels + framesrun - 1), ((*(debugframevels + framesrun - 1) / PIXELS_METER) * FPS), (frametime - timestart) / (float)1000, framesrun); + + if (debugframevels != NULL) { + for (i = 0; i < (int)framesrun; i++) { + printf("Frame %d: %f\n", i, *(debugframevels+i)); + } + } + } + + if (debugframevels != NULL) + *(debugframevels + framesrun) = sprite->getVel(); + framesrun++; + + } + + sprintf(debugstring, "Frametime %lu", frametime - lastframetime); + SDL_FillRect(screen, &screen_r, screen_c); + filledPolygonColor(screen, slope_v_x, slope_v_y, slope_v_size, 0x0000ffff); + filledCircleColor(screen, sprite->getXPixels(), sprite->getYPixels(), BALL_RADIUS, 0xff0000ff); + stringColor(screen, 10, SCREEN_HEIGHT - 15, debugstring, 0xffffff99); + SDL_Flip(screen); + + lastframetime = frametime; + + //if (lastframetime - frametime < minframetime) + //SDL_Delay (minframetime - (SDL_GetTicks () - frametime)); + SDL_Delay(minframetime); + + + } + + delete(sprite); + SDL_FreeSurface(screen); + SDL_Quit(); + + return 0; +} diff --git a/c++/tests/sprite.cpp b/c++/tests/sprite.cpp @@ -0,0 +1,83 @@ +// test sprite functions + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <stdint.h> + +#include "../lash_game_sprite.h" + +void dumpsprite(Lash_Sprite_2D_Simple *sprite, char *description) { + + printf("%s:\nx %.2f, y %.2f, w %d, h %d, ax %.2f, ay %.2f, vx %.2f, vy %.2f\n", description, sprite->getX(), sprite->getY(), sprite->getW(), sprite->getH(), sprite->getAccelerationX(0), sprite->getAccelerationY(0), sprite->getVelX(), sprite->getVelY()); + //printf("%s:\nx %.2f, y %.2f, w %d, h %d, a %.2f, ra %.2f, v %.2f, rv %.2f\n", description, sprite->getX(), sprite->getY(), sprite->getW(), sprite->getH(), sprite->getAccelerationX(0), sprite->getAccelerationY(0), sprite->getVelX(), sprite->getVelY()); + static char statestring[33]; + sprite->dumpState(statestring); + printf("state is now 0x%s\n\n", statestring); +} + +int main() { + srand(clock()); + float x = rand() % 127; + float y = rand() % 127; + uint32_t w = rand() % 127; + uint32_t h = rand() % 127; + float inita = 0.3; + float inca = 0.4; + char *description = (char*)malloc(sizeof(char)*255); + Lash_Sprite_2D_Simple *sprite = new Lash_Sprite_2D_Simple(w, h, inita, inca); + + sprintf(description, "Sprite init %p w %d h %d", sprite, w, h); + dumpsprite(sprite, description); + + sprite->setX(x); + sprintf(description, "Set X %.2f", x); + dumpsprite(sprite, description); + + sprite->setY(y); + sprintf(description, "Set Y %.2f", y); + dumpsprite(sprite, description); + + sprite->walkLeft(); + strcpy(description, "Walkleft\0"); + dumpsprite(sprite, description); + + sprite->move(); + strcpy(description, "Move\0"); + dumpsprite(sprite, description); + + sprite->accelerate(); + strcpy(description, "Accelerate\0"); + dumpsprite(sprite, description); + + sprite->move(); + strcpy(description, "Move\0"); + dumpsprite(sprite, description); + + sprite->addAccelerationX(0.6); + sprintf(description, "Add acceleration %f", 0.6); + dumpsprite(sprite, description); + + sprite->accelerate(); + strcpy(description, "Accelerate\0"); + dumpsprite(sprite, description); + + sprite->move(); + strcpy(description, "Move\0"); + dumpsprite(sprite, description); + + sprite->jump(); + strcpy(description, "Jump\0"); + dumpsprite(sprite, description); + + sprite->land(); + strcpy(description, "Land\0"); + dumpsprite(sprite, description); + + sprite->stop(); + strcpy(description, "Stop\0"); + dumpsprite(sprite, description); + + return 0; +} diff --git a/c++/tests/spritesetvel.cpp b/c++/tests/spritesetvel.cpp @@ -0,0 +1,46 @@ +// sprite setvel tests + +#include "../lash_game_sprite.h" +#include <stdio.h> +#include <math.h> + +int main(int argc, char *argv[]) { + Lash_Sprite_2D_Simple *sprite = new Lash_Sprite_2D_Simple(); + /*float ox = -32.8112793; + float ny = 94.9453812; + float nx = -31.390686; + float oy = 94.4638519; + */ + + float testx = 2.f; + float testy = 3.f; + float testd = sqrt(pow(testx, 2) + pow(testy, 2)); + float testa = atan2(-testy, testx); + + float r; + float v; + + sprite->init(200, 200, 0.f, 0.f); + + sprite->setVelX(testx, 0); + sprite->getVel(&v, &r); + printf("getvel after init setvelx %f = v %f, r %f\n", testx, v, r); + sprite->setVelY(testy, 1); + sprite->getVel(&v, &r); + printf("getvel after setvely (keep x) %f = v %f, r %f\n", testy, v, r); + sprite->setVel(testd, testa); + sprite->getVel(&v, &r); + printf("getvel after setvel %f, r %f = v %f, r %f\n", testd, testa, v, r); + + sprite->setVelY(testy, 0); + sprite->getVel(&v, &r); + printf("getvel after init setvely %f = v %f, r %f\n", testy, v, r); + sprite->setVelX(testx, 1); + sprite->getVel(&v, &r); + printf("getvel after setvelx (keep y) %f = v %f, r %f\n", testx, v, r); + sprite->setVel(testd, testa); + sprite->getVel(&v, &r); + printf("getvel after setvel %f, r %f = v %f, r %f\n", testd, testa, v, r); + + return 0; +} diff --git a/configure.in b/configure.in @@ -0,0 +1,5568 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for FULL-PACKAGE-NAME VERSION. +# +# Report bugs to <BUG-REPORT-ADDRESS>. +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and BUG-REPORT-ADDRESS +$0: about your system, including any error possibly output +$0: before this message. Then install a modern shell, or +$0: manually run the script under such a shell if you do +$0: have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 </dev/null +exec 6>&1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='FULL-PACKAGE-NAME' +PACKAGE_TARNAME='full-package-name' +PACKAGE_VERSION='VERSION' +PACKAGE_STRING='FULL-PACKAGE-NAME VERSION' +PACKAGE_BUGREPORT='BUG-REPORT-ADDRESS' +PACKAGE_URL='' + +ac_unique_file="lash_game_map.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#ifdef STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# ifdef HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +EGREP +GREP +CPP +ac_ct_CC +CFLAGS +CC +OBJEXT +EXEEXT +ac_ct_CXX +CPPFLAGS +LDFLAGS +CXXFLAGS +CXX +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +' + ac_precious_vars='build_alias +host_alias +target_alias +CXX +CXXFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCC +CC +CFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures FULL-PACKAGE-NAME VERSION to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root + [DATAROOTDIR/doc/full-package-name] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of FULL-PACKAGE-NAME VERSION:";; + esac + cat <<\_ACEOF + +Some influential environment variables: + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if + you have headers in a nonstandard directory <include dir> + CC C compiler command + CFLAGS C compiler flags + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to <BUG-REPORT-ADDRESS>. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +FULL-PACKAGE-NAME configure VERSION +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## --------------------------------- ## +## Report this to BUG-REPORT-ADDRESS ## +## --------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_find_intX_t LINENO BITS VAR +# ----------------------------------- +# Finds a signed integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_intX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 +$as_echo_n "checking for int$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in int$2_t 'int' 'long int' \ + 'long long int' 'short int' 'signed char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + enum { N = $2 / 2 - 1 }; +int +main () +{ +static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + enum { N = $2 / 2 - 1 }; +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) + < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + case $ac_type in #( + int$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_intX_t + +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_uintX_t + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case <limits.h> declares $2. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by FULL-PACKAGE-NAME $as_me VERSION, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_config_headers="$ac_config_headers config.h" + + +# Checks for programs. +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 +$as_echo_n "checking whether the C++ compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C++ compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 +$as_echo_n "checking for C++ compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lSDL': + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lSDL" >&5 +$as_echo_n "checking for main in -lSDL... " >&6; } +if ${ac_cv_lib_SDL_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lSDL $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_SDL_main=yes +else + ac_cv_lib_SDL_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_SDL_main" >&5 +$as_echo "$ac_cv_lib_SDL_main" >&6; } +if test "x$ac_cv_lib_SDL_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSDL 1 +_ACEOF + + LIBS="-lSDL $LIBS" + +fi + +# FIXME: Replace `main' with a function in `-lSDL_gfx': +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lSDL_gfx" >&5 +$as_echo_n "checking for main in -lSDL_gfx... " >&6; } +if ${ac_cv_lib_SDL_gfx_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lSDL_gfx $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_SDL_gfx_main=yes +else + ac_cv_lib_SDL_gfx_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_SDL_gfx_main" >&5 +$as_echo "$ac_cv_lib_SDL_gfx_main" >&6; } +if test "x$ac_cv_lib_SDL_gfx_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSDL_GFX 1 +_ACEOF + + LIBS="-lSDL_gfx $LIBS" + +fi + +# FIXME: Replace `main' with a function in `-llash': +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -llash" >&5 +$as_echo_n "checking for main in -llash... " >&6; } +if ${ac_cv_lib_lash_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-llash $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_lash_main=yes +else + ac_cv_lib_lash_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lash_main" >&5 +$as_echo "$ac_cv_lib_lash_main" >&6; } +if test "x$ac_cv_lib_lash_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBLASH 1 +_ACEOF + + LIBS="-llash $LIBS" + +fi + +# FIXME: Replace `main' with a function in `-llashgame': +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -llashgame" >&5 +$as_echo_n "checking for main in -llashgame... " >&6; } +if ${ac_cv_lib_lashgame_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-llashgame $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_lashgame_main=yes +else + ac_cv_lib_lashgame_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lashgame_main" >&5 +$as_echo "$ac_cv_lib_lashgame_main" >&6; } +if test "x$ac_cv_lib_lashgame_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBLASHGAME 1 +_ACEOF + + LIBS="-llashgame $LIBS" + +fi + +# FIXME: Replace `main' with a function in `-lm': +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lm" >&5 +$as_echo_n "checking for main in -lm... " >&6; } +if ${ac_cv_lib_m_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_main=yes +else + ac_cv_lib_m_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_main" >&5 +$as_echo "$ac_cv_lib_m_main" >&6; } +if test "x$ac_cv_lib_m_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +fi + + +# Checks for header files. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ctype.h> +#include <stdlib.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in stdint.h stdlib.h string.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 +$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } +if ${ac_cv_header_stdbool_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include <stdbool.h> + #ifndef bool + "error: bool is not defined" + #endif + #ifndef false + "error: false is not defined" + #endif + #if false + "error: false is not 0" + #endif + #ifndef true + "error: true is not defined" + #endif + #if true != 1 + "error: true is not 1" + #endif + #ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" + #endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + /* See body of main program for 'e'. */ + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + +int +main () +{ + + bool e = &s; + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdbool_h=yes +else + ac_cv_header_stdbool_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 +$as_echo "$ac_cv_header_stdbool_h" >&6; } + ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" +if test "x$ac_cv_type__Bool" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE__BOOL 1 +_ACEOF + + +fi + + +ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t" +case $ac_cv_c_int16_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<_ACEOF +#define int16_t $ac_cv_c_int16_t +_ACEOF +;; +esac + +ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" +case $ac_cv_c_int32_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<_ACEOF +#define int32_t $ac_cv_c_int32_t +_ACEOF +;; +esac + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" +case $ac_cv_c_uint16_t in #( + no|yes) ;; #( + *) + + +cat >>confdefs.h <<_ACEOF +#define uint16_t $ac_cv_c_uint16_t +_ACEOF +;; + esac + +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT32_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + +ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" +case $ac_cv_c_uint8_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT8_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint8_t $ac_cv_c_uint8_t +_ACEOF +;; + esac + + +# Checks for library functions. +for ac_header in stdlib.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STDLIB_H 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 +$as_echo_n "checking for GNU libc compatible malloc... " >&6; } +if ${ac_cv_func_malloc_0_nonnull+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_malloc_0_nonnull=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include <stdlib.h> +#else +char *malloc (); +#endif + +int +main () +{ +return ! malloc (0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_malloc_0_nonnull=yes +else + ac_cv_func_malloc_0_nonnull=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 +$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } +if test $ac_cv_func_malloc_0_nonnull = yes; then : + +$as_echo "#define HAVE_MALLOC 1" >>confdefs.h + +else + $as_echo "#define HAVE_MALLOC 0" >>confdefs.h + + case " $LIBOBJS " in + *" malloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS malloc.$ac_objext" + ;; +esac + + +$as_echo "#define malloc rpl_malloc" >>confdefs.h + +fi + + +for ac_header in stdlib.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STDLIB_H 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 +$as_echo_n "checking for GNU libc compatible realloc... " >&6; } +if ${ac_cv_func_realloc_0_nonnull+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_realloc_0_nonnull=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include <stdlib.h> +#else +char *realloc (); +#endif + +int +main () +{ +return ! realloc (0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_realloc_0_nonnull=yes +else + ac_cv_func_realloc_0_nonnull=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 +$as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } +if test $ac_cv_func_realloc_0_nonnull = yes; then : + +$as_echo "#define HAVE_REALLOC 1" >>confdefs.h + +else + $as_echo "#define HAVE_REALLOC 0" >>confdefs.h + + case " $LIBOBJS " in + *" realloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS realloc.$ac_objext" + ;; +esac + + +$as_echo "#define realloc rpl_realloc" >>confdefs.h + +fi + + +for ac_func in floor pow sqrt +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +ac_config_files="$ac_config_files Makefile c++/Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by FULL-PACKAGE-NAME $as_me VERSION, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to <BUG-REPORT-ADDRESS>." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +FULL-PACKAGE-NAME config.status VERSION +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "c++/Makefile") CONFIG_FILES="$CONFIG_FILES c++/Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' <conf$$subs.awk | sed ' +/^[^""]/{ + N + s/\n// +} +' >>$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' <confdefs.h | sed ' +s/'"$ac_delim"'/"\\\ +"/g' >>$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/cpython/lash_game_map_setup.py b/cpython/lash_game_map_setup.py @@ -0,0 +1,18 @@ +from distutils.core import setup, Extension + +module1 = Extension('lashgamemap', + sources = ['lash_game_map_wrapper.c'], + libraries = ['lashgamemap', 'lashgame', 'lash'], + #libraries = ['lashgame', 'lash'], + library_dirs = ['/home/lash/programming/lib'], + #include_dirs = ['/home/lash/programming/src/liblashgame/'], + #extra_objects = [ '/home/lash/programming/src/liblashgame/lash_game_path_simple.o', + # '/home/lash/programming/src/liblashgame/lash_game_map.o'], + include_dirs = ['/home/lash/programming/include'] + + ) + +setup (name = 'lashgamemap', + version = '1.0', + description = 'Map and path functions', + ext_modules = [module1]) diff --git a/cpython/lash_game_map_wrapper.c b/cpython/lash_game_map_wrapper.c @@ -0,0 +1,310 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "Python.h" + +#include "liblashgame/lash_game_map.h" +#include "liblashgame/lash_game_path_simple.h" + +void mapDestroy(PyObject *capsule) { + + lash_map_simple_t *map; + + //fprintf(stderr, "Entered destructor\n"); + + map = (lash_map_simple_t*)PyCapsule_GetPointer(capsule, "MAP_C_API"); + if (map == NULL) + return; + + //fprintf(stderr, "Destroying map %p\n", map); + + lash_mapSimpleFree(map); + free(map); + +} + +static PyObject * mapSimpleInit_func(PyObject *self, PyObject *args) { + unsigned int w; + unsigned int h; + PyObject *pymap; + + lash_map_simple_t *map = (lash_map_simple_t*)malloc(sizeof(lash_map_simple_t)); + + if (!PyArg_ParseTuple(args, "II", &w, &h)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + if (!lash_mapSimpleInit(map, &w, &h)) { + PyErr_SetString(PyExc_RuntimeError, "Cannot initialize map! "); + return NULL; + } + + + pymap = PyCapsule_New((void *)map, "MAP_C_API", mapDestroy); + + // free(map); + + return Py_BuildValue("O", pymap); + +} + +static PyObject * mapSimplePeek_func(PyObject *self, PyObject *args) { + lash_game_map_index_t idx; + lash_map_simple_t *map; + PyObject *pymap; + + if (!PyArg_ParseTuple(args, "Ok", &pymap, &idx)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + map = (lash_map_simple_t*)PyCapsule_GetPointer(pymap, "MAP_C_API"); + + if (idx >= *(map->w) * *(map->h)) + return NULL; + + return Py_BuildValue("h", (unsigned short)lash_mapSimpleLayerPeek(map->layer_path, idx)); +} + +static PyObject * mapSimplePoke_func(PyObject *self, PyObject *args) { + lash_game_map_index_t idx; + unsigned short val; + lash_map_simple_t *map; + PyObject *pymap; + + if (!PyArg_ParseTuple(args, "Okh", &pymap, &idx, &val)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + map = (lash_map_simple_t*)PyCapsule_GetPointer(pymap, "MAP_C_API"); + + if (idx < *(map->w) * *(map->h)) + lash_mapSimpleLayerPoke(map->layer_path, idx, (lash_map_simple_layer_item_t)val); + + return Py_BuildValue("s", NULL); +} + +static PyObject * getMapSizeUnits_func(PyObject *self, PyObject *args) { + + lash_map_simple_t *map; + PyObject *pymap; + + if (!PyArg_ParseTuple(args, "O", &pymap)) + return NULL; + + map = (lash_map_simple_t*)PyCapsule_GetPointer(pymap, "MAP_C_API"); + if (map == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Invalid map object"); + return NULL; + } + + return Py_BuildValue("II", *(map->w), *(map->h)); + +} + +static PyObject * getPathFreeSpaces_func(PyObject *self, PyObject *args) { + int i; + + lash_map_simple_t *map; + + // args + PyObject *pymap; + + // process + unsigned int mapsize; + + // result + unsigned int *freeindices; + int freeindices_count; + PyObject *freeindices_final; + + if (!PyArg_ParseTuple(args, "O", &pymap)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + map = (lash_map_simple_t*)PyCapsule_GetPointer(pymap, "MAP_C_API"); + if (map == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Invalid map object"); + return NULL; + } + + mapsize = lash_mapSimpleGetSize(map); + + freeindices = (unsigned int*)calloc(sizeof(unsigned int), mapsize); + if (freeindices == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Could not allocate array to hold free spaces index list"); + return NULL; + } + + freeindices_count = lash_pathSimpleCompileFreeSpaces(&freeindices, mapsize, map->layer_path, mapsize, NULL, 0); + + if (freeindices_count == -1) { + PyErr_SetString(PyExc_RuntimeError, "List compilation of free spaces failed"); + return NULL; + } + + freeindices_final = PyList_New(freeindices_count); + + for (i = 0; i < freeindices_count; i++) { + PyObject *newindex = Py_BuildValue("I", (unsigned int)*(freeindices + i)); + //if (PyList_SetItem(freeindices_final, i, PyBytes_FromFormat("%u", (unsigned int)*(freeindices + i))) == -1) { + if (PyList_SetItem(freeindices_final, i, newindex) == -1) { + PyErr_SetString(PyExc_RuntimeError, "Could not complete populating final free spaces index array"); + return NULL; + } + } + + free(freeindices); + return freeindices_final; +} + +static PyObject * makeSimplePath_func(PyObject *self, PyObject *args) { + + int i; + + lash_map_simple_t *map; + lash_path_simple_t path; + lash_path_simple_space_t *space; + lash_path_simple_space_t *nextspace; + unsigned int *pathindices; + + // args + PyObject *pymap; + unsigned int index_start; + unsigned int index_end; + + // processing + unsigned int steps; + + // output + PyObject *path_final; + + + if (!PyArg_ParseTuple(args, "OII", &pymap, &index_start, &index_end)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + map = (lash_map_simple_t*)PyCapsule_GetPointer(pymap, "MAP_C_API"); + if (map == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Invalid map object"); + return NULL; + } + + if (lash_pathSimpleNew(&path, map, index_start, index_end) == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Could not initialize path object"); + return NULL; + } + + lash_pathSimpleNext(&path, &space); + + steps = 0; + + while (space->index != path.target) { + lash_pathSimpleStepProcess(&path, map, space, NULL, 0); + steps++; + lash_pathSimpleNext(&path, &space); + + if (space == NULL) { + return Py_None; + } + } + + pathindices = (unsigned int*)calloc(sizeof(unsigned int), steps * 2); + if (pathindices == NULL){ + PyErr_SetString(PyExc_RuntimeError, "Could not initialize array for final path storage"); + return NULL; + } + + *(pathindices + 0) = space->index; + + nextspace = space; + + steps = 0; + + while (nextspace->parent != NULL) { + steps++; + space = nextspace; + nextspace = space->parent; + *(pathindices + steps) = nextspace->index; + } + + i = 0; + + path_final = PyList_New(steps); + + for (i = 0; i < steps; i++) { + //if (PyList_SetItem(path_final, i, PyBytes_FromFormat("%u", *(pathindices + i))) == -1) { + if (PyList_SetItem(path_final, i, Py_BuildValue("I", *(pathindices + i))) == -1) { + PyErr_SetString(PyExc_RuntimeError, "Could not complete populating final path index array"); + if (pathindices != NULL) + free(pathindices); + return NULL; + } + } + + if (pathindices != NULL) + free(pathindices); + + lash_pathSimpleFree(&path); + + return path_final; +} + +static PyObject * pathInit_func(PyObject *self, PyObject *args) { + + return Py_BuildValue("i", lash_pathSimpleInit()); + +} + +static PyObject * pathFinish_func(PyObject *self, PyObject *args) { + lash_pathSimpleFinish(); + return Py_None; +} + +static PyObject * mapSimpleFree_func(PyObject *self, PyObject *args) { + lash_map_simple_t *map; + PyObject *pymap; + + if (!PyArg_ParseTuple(args, "O", &pymap)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + map = (lash_map_simple_t*)PyCapsule_GetPointer(pymap, "MAP_C_API"); + + lash_mapSimpleFree(map); + free(map); + + return Py_None; +} + +static PyMethodDef PylashgamemapMethods[] = { + {"mapSimpleInit", (PyCFunction)mapSimpleInit_func, METH_VARARGS, "Initialize a new map object"}, + {"mapSimplePeek", (PyCFunction)mapSimplePeek_func, METH_VARARGS, "Get an obstacle value at a certain index"}, + {"mapSimplePoke", (PyCFunction)mapSimplePoke_func, METH_VARARGS, "Set an obstacle value at a certain index"}, + {"mapSimpleFree", (PyCFunction)mapSimpleFree_func, METH_VARARGS, "Frees resources used by map object"}, + {"getMapSizeUnits", (PyCFunction)getMapSizeUnits_func, METH_VARARGS, "Return with and height in units"}, + {"makeSimplePath", (PyCFunction)makeSimplePath_func, METH_VARARGS, "Returns shortest path between two points using the specified layerpath"}, + {"getPathFreeSpaces", (PyCFunction)getPathFreeSpaces_func, METH_VARARGS, "Get map indices of free spaces from map layer path"}, + {"pathInit", (PyCFunction)pathInit_func, METH_VARARGS, "Initialize the pathfinder library"}, + {"pathFinish", (PyCFunction)pathFinish_func, METH_VARARGS, "Clean the pathfinder library"}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef lashgamemapmodule = { + PyModuleDef_HEAD_INIT, + "lashgamemap", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + PylashgamemapMethods +}; + +PyMODINIT_FUNC PyInit_lashgamemap(void) +{ + return PyModule_Create(&lashgamemapmodule); +} diff --git a/cpython/lash_game_standard_setup.py b/cpython/lash_game_standard_setup.py @@ -0,0 +1,16 @@ +from distutils.core import setup, Extension + +module1 = Extension('lashgame', + sources = ['lash_game_standard_wrapper.c'], + libraries = ['lashgame'], + library_dirs = ['/home/lash/programming/lib'], + #include_dirs = ['/home/lash/programming/src/liblashgame/'], + #extra_objects = ['lash_game_standard.o'] + include_dirs = ['/home/lash/programming/include'] + + ) + +setup (name = 'lashgame', + version = '1.0', + description = 'Standard game arithmetic functions', + ext_modules = [module1]) diff --git a/cpython/lash_game_standard_wrapper.c b/cpython/lash_game_standard_wrapper.c @@ -0,0 +1,235 @@ +#include "Python.h" +#include "liblashgame/lash_game_standard.h" +#include <stdio.h> + +/** + * \version 0.3 Added cartesianToLinear, collisionCircleLine, compareAngleSpan + * \version 0.2 Added getCartesianMagnitude + */ + + +static PyObject * compareAngleSpan_func(PyObject *self, PyObject *args) { + + enum lash_anglespan_compare result; + char *resultstring; + float oldradmin; + float oldradmax; + float newradmin; + float newradmax; + + if (!PyArg_ParseTuple(args, "ffff", &oldradmin, &oldradmax, &newradmin, &newradmax)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + result = lash_compareAngleSpan(oldradmin, oldradmax, newradmin, newradmax); + + switch(result) { + case LASH_ANGLESPAN_NONE: + resultstring = "none"; + break; + case LASH_ANGLESPAN_MAX: + resultstring = "max"; + break; + case LASH_ANGLESPAN_MIN: + resultstring = "min"; + break; + case LASH_ANGLESPAN_BOTH: + resultstring = "minmax"; + break; + case LASH_ANGLESPAN_SPLIT: + resultstring = "split"; + break; + default: + resultstring = "error"; + } + + return Py_BuildValue("s", resultstring); + + +} + +static PyObject * collisionCircleLine_func(PyObject *self, PyObject *args) { + + lash_game_line_t line; + float circle_radius; + lash_game_coords_float_t circle_coords; + lash_game_coords_float_t intersect_a; + lash_game_coords_float_t intersect_b; + char numintersections; + + if (!PyArg_ParseTuple(args, "ddfdd", &circle_coords.x, &circle_coords.y, &circle_radius, &line.m, &line.c)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + numintersections = lash_collisionCircleLine(circle_coords, circle_radius, line, &intersect_a, &intersect_b); + + if (numintersections == 2) { + return Py_BuildValue("ffff", intersect_a.x, intersect_a.y, intersect_b.x, intersect_b.y); + } else if (numintersections == 1) { + return Py_BuildValue("ffff", intersect_a.x, intersect_a.y); + } + + return Py_None; + + +} + +static PyObject * cartesianToLinear_func(PyObject *self, PyObject *args) { + + lash_game_line_t line; + lash_game_coords_float_t source; + lash_game_coords_float_t target; + + if (!PyArg_ParseTuple(args, "dddd", &source.x, &source.y, &target.x, &target.y)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + lash_cartesianToLinear(source, target, &line); + + return Py_BuildValue("ff", line.m, line.c); +} + +static PyObject * cartesianMagnitude_func(PyObject *self, PyObject *args) { + + int targetx; + int targety; + int sourcex; + int sourcey; + + if (!PyArg_ParseTuple(args, "iiii", &targetx, &targety, &sourcex, &sourcey)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + return Py_BuildValue("f", lash_cartesianMagnitude(targetx, targety, sourcex, sourcey)); +} + +static PyObject * getContainedAngle_func(PyObject *self, PyObject *args) { + double x; + double y; + double m; + double w; + double h; + int bt, br, bb, bl; + + + double max_r; + double min_r; + double max_x; + double max_y; + double min_x; + double min_y; + + if (!PyArg_ParseTuple(args, "dddddIIII", &x, &y, &m, &w, &h, &bt, &br, &bb, &bl)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + + lash_getContainedAngle(x, y, m, w, h, bt, br, bb, bl, &min_r, &max_r, 1, &min_x, &min_y, &max_x, &max_y); + + return Py_BuildValue("dddddd", min_r, max_r, min_x, min_y, max_x, max_y); + + +} + +static PyObject * indexToCartesian_func(PyObject *self, PyObject *args) { + unsigned int w; + unsigned int h; + lash_game_map_index_t idx; + unsigned int unitsize; + lash_game_coords_t vtx; + vtx.x = 0; + vtx.y = 0; + + if (!PyArg_ParseTuple(args, "IIkI", &w, &h, &idx, &unitsize)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + lash_indexToCartesian(&vtx, &w, &h, &unitsize, &idx); + + return Py_BuildValue("II", vtx.x, vtx.y); + +} + +static PyObject * cartesianToIndex_func(PyObject *self, PyObject *args) { + unsigned int w; + unsigned int h; + lash_game_map_index_t idx; + unsigned int unitsize; + lash_game_coords_t vtx; + + if (!PyArg_ParseTuple(args, "IIIII", &w, &h, &vtx.x, &vtx.y, &unitsize)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + lash_cartesianToIndex(&idx, &w, &h, &unitsize, &vtx); + + return Py_BuildValue("I", (unsigned int)idx); + +} + +static PyObject * cartesianToPolar_func(PyObject *self, PyObject *args) { + + int sourcex; + int sourcey; + int targetx; + int targety; + float radians; + float radius; + int invx; + int invy; + + if (!PyArg_ParseTuple(args, "iiiiii", &sourcex, &sourcey, &targetx, &targety, &invx, &invy)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + lash_cartesianToPolar(sourcex, sourcey, targetx, targety, &radians, &radius, invx, invy); + + return Py_BuildValue("ff", radians, radius); +} + +static PyObject * normalizeRadians_func(PyObject *self, PyObject *args) { + + float rin; + + if (!PyArg_ParseTuple(args, "f", &rin)) { + PyErr_SetString(PyExc_RuntimeError, "Invalid input"); + return NULL; + } + + return Py_BuildValue("f", lash_normalizeRadians(rin)); +} + +static PyMethodDef PylashgameMethods[] = { + {"cartesianMagnitude", (PyCFunction)cartesianMagnitude_func, METH_VARARGS, "Distance between two (2d) points"}, + {"compareAngleSpan", (PyCFunction)compareAngleSpan_func, METH_VARARGS, "Determine action to be taken to deduct one angle span from the other"}, + {"indexToCartesian", (PyCFunction)indexToCartesian_func, METH_VARARGS, "Convert from index in tiled rectangle to cartesian coordinate"}, + {"cartesianToIndex", (PyCFunction)cartesianToIndex_func, METH_VARARGS, "Convert from cartesian coordinate to index in tiled rectangle"}, + {"getContainedAngle", (PyCFunction)getContainedAngle_func, METH_VARARGS, "Get the minimum and maximum radians from a position in a plane still contained with given radius"}, + {"cartesianToPolar", (PyCFunction)cartesianToPolar_func, METH_VARARGS, "Converts cartesian coords to polar coords"}, + {"cartesianToLinear", (PyCFunction)cartesianToLinear_func, METH_VARARGS, "Converts cartesian coords to magnitude and y intersect"}, + {"normalizeRadians", (PyCFunction)normalizeRadians_func, METH_VARARGS, "Converts negative and positive radians to 2pi > radians > 0"}, + {"collisionCircleLine", (PyCFunction)collisionCircleLine_func, METH_VARARGS, "Intersection coords between circle and line"}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef lashgamemodule = { + PyModuleDef_HEAD_INIT, + "lashgame", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + PylashgameMethods +}; + +PyMODINIT_FUNC PyInit_lashgame(void) +{ + return PyModule_Create(&lashgamemodule); +} diff --git a/lash_game_color.c b/lash_game_color.c @@ -0,0 +1,5 @@ +#include "lash_game_color.h" + +lash_color_t lash_mapColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { + return r << 24 | g << 16 | b << 8 | a; +} diff --git a/lash_game_color.h b/lash_game_color.h @@ -0,0 +1,16 @@ +#ifndef LASH_GAME_COLOR_H_ +#define LASH_GAME_COLOR_H_ + +#include <stdint.h> + +typedef uint32_t lash_color_t; + +#ifdef __cplusplus +extern "C" { +#endif +lash_color_t lash_mapColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a); +#ifdef __cplusplus +} +#endif + +#endif // LASH_GAME_COLOR_H_ diff --git a/lash_game_map.c b/lash_game_map.c @@ -0,0 +1,130 @@ +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include "liblashgame/lash_game_map.h" +#include "liblashgame/lash_game_standard.h" + +lash_map_simple_t * lash_mapSimpleInit(lash_map_simple_t *map, unsigned int *w, unsigned int *h) { + map->w = (unsigned int*)malloc(sizeof(unsigned int)); + map->h = (unsigned int*)malloc(sizeof(unsigned int)); + map->layer_count = 0; + *(map->w) = *w; + *(map->h) = *h; + map->layers = (lash_map_simple_layer_t**)malloc(sizeof(lash_map_simple_layer_t*) * LASH_GAME_MAP_SIMPLE_DEFAULT_LAYERS); + map->layer_path = lash_mapSimpleAddLayer(map); + return map; +} + +void lash_mapSimpleFree(lash_map_simple_t *map) { + int i; + + if (map->w != NULL) + free(map->w); + + if (map->h != NULL) + free(map->h); + + for (i = 0; i < map->layer_count; i++) { + if ((map->layers + i) != NULL) + free(map->layers + i); + } + +} + +int lash_mapSimpleGetSize(lash_map_simple_t *map) { + if (map == NULL) + return -1; + + return *(map->w) * *(map->h); +} + +lash_map_simple_layer_t * lash_mapSimpleAddLayer(lash_map_simple_t *map) { + lash_map_simple_layer_t *newlayer; + newlayer = (lash_map_simple_layer_t*)malloc(*(map->w) * *(map->h) * sizeof(lash_map_simple_layer_item_t)); + if (newlayer == NULL) + return NULL; + *(map->layers + map->layer_count) = newlayer; + map->layer_count ++; + return newlayer; +} + +void lash_mapSimpleLayerPoke(lash_map_simple_layer_t *layer, const lash_game_map_index_t index, const lash_map_simple_layer_item_t value) { + if (layer == NULL) + return; + + (layer+index)->val = value; +} + +lash_map_simple_layer_item_t lash_mapSimpleLayerPeek(lash_map_simple_layer_t *layer, const lash_game_map_index_t index) { + if (layer == NULL) + return -1; + + return (layer+index)->val; +} + +lash_map_simple_t * lash_mapSimpleClip(lash_map_simple_t *clipmap, lash_map_simple_t *sourcemap, const unsigned int clip_x_radius, const unsigned int clip_y_radius, const lash_game_map_index_t clip_origin_index, enum lash_game_map_alignment clip_origin_alignment, int include_path_only) { + + int i; + + unsigned int delta_left; + unsigned int delta_right; + unsigned int delta_top; + unsigned int delta_bottom; + + unsigned int clip_y_top; + unsigned int clip_y_bottom; + unsigned int clip_x_left; + unsigned int clip_x_right; + + unsigned int clip_width; + unsigned int clip_height; + + //lash_game_coords_cartesian_t map_coords_bounds; + lash_game_map_index_t map_index_last; + + // if no valid source map + if (sourcemap == NULL) + return NULL; + else if (*sourcemap->w == 0 || *sourcemap->h == 0) + return NULL; + + map_index_last = (*sourcemap->w * *sourcemap->h) - 1; + + if (clip_origin_index > map_index_last) + return NULL; + + // this will always clip from center + // also make possible clip from topleft + delta_top = (int)floor(clip_origin_index / *sourcemap->w); + delta_bottom = *sourcemap->h - delta_top - 1; + delta_left = clip_origin_index - delta_top * *sourcemap->w; + delta_right = ((delta_top + 1) * *sourcemap->w) - clip_origin_index - 1; + + clip_y_top = clip_y_radius > delta_top ? delta_top : clip_y_radius; + clip_y_bottom = clip_y_radius > delta_bottom ? delta_bottom : clip_y_radius; + clip_x_left = clip_x_radius > delta_left ? delta_left : clip_x_radius; + clip_x_right = clip_x_radius > delta_right ? delta_right : clip_x_radius; + + clip_width = (clip_x_right + clip_x_left + 1); + clip_height = (clip_y_bottom + clip_y_top + 1); + + // we now have the size of the clip and the coords to cut + + lash_mapSimpleInit(clipmap, &clip_width, &clip_height); + + if (!include_path_only) { + for (i = 0; i < sourcemap->layer_count; i++) { + lash_mapSimpleAddLayer(clipmap); + } + } + + // and fill in with values from the main map + + for (i = clip_height - 1; i > -1; i--) { + int cpos = clip_origin_index - (*sourcemap->w * (i - delta_bottom)) - clip_x_left; + memcpy((*clipmap->layers + ((clip_height - 1 - i) * clip_width)), (*sourcemap->layers + cpos), clip_width * sizeof(lash_map_simple_layer_item_t)); + } + + return clipmap; +} diff --git a/lash_game_map.h b/lash_game_map.h @@ -0,0 +1,81 @@ +#ifndef LASH_GAME_MAP_SIMPLE_H_ +#define LASH_GAME_MAP_SIMPLE_H_ + +#define LASH_GAME_MAP_SIMPLE_DEFAULT_LAYERS 3 + +#include "liblashgame/lash_game_standard.h" + + // considered doing this with pointer to pointer, to allow one map object be a clip of another and point to the same data sources, but: + // + // upside: data only in one place; change it in map, change it in clip + // downsize: pointers are twice the size of unsigned int, twice the memory to reserve for maps and then later move for clips + // Here is a possible implementation: + // + // keep the actual values in a separate array, + // (this is the same solution as in lash_game_path_simple) + // + // c.layervalues = (unsigned int*)malloc(sizeof(unsigned int) * 400); + // *c.layervalues = 10; + // *c.layervalues = 20; + // + // Highest pointer level is pointers to the individual layers + // + // c.layers = (unsigned int ***)malloc(sizeof(unsigned int) * 2); + // + // Second pointer level the individual entries are pointers to the values in c.layervalues + // + // *(c.layers + 0) = (unsigned int **)malloc(sizeof(unsigned int) * 100); + // *(c.layers + 1) = (unsigned int **)malloc(sizeof(unsigned int) * 100); + // + // Pointers can be assigned on the third level + // + // **(c.layers + 0) = c.layervalues; + // *(*(c.layers + 1) + 1) = c.layervalues; + // + // printf("pointer address layer %p : %p layer %p : %p in layervalues %p\n", *(c.layers + 0), **(c.layers + 0), *(c.layers + 1), *(*(c.layers + 1) + 1), c.layervalues); + +typedef unsigned short lash_map_simple_layer_item_t; + +typedef struct lash_map_simple_layer_t lash_map_simple_layer_t; + +struct lash_map_simple_layer_t { + lash_map_simple_layer_item_t val; +}; + +typedef struct lash_map_simple_t lash_map_simple_t; + +struct lash_map_simple_t { + unsigned int *w; + unsigned int *h; + lash_map_simple_layer_t **layers; + unsigned char layer_count; + lash_map_simple_layer_t *layer_path; +}; + +enum lash_game_map_alignment { + LASH_GAME_MAP_OFFSET_CENTER, + LASH_GAME_MAP_OFFSET_TOPLEFT, + LASH_GAME_MAP_OFFSET_BOTTOMLEFT, + LASH_GAME_MAP_OFFSET_BOTTOMRIGHT, + LASH_GAME_MAP_OFFSETP_TOPRIGHT +}; + +lash_map_simple_t * lash_mapSimpleInit(lash_map_simple_t *map, unsigned int *w, unsigned int *h); +void lash_mapSimpleFree(lash_map_simple_t *map); +lash_map_simple_layer_t * lash_mapSimpleAddLayer(lash_map_simple_t *map); +void lash_mapSimpleLayerPoke(lash_map_simple_layer_t *layer, const lash_game_map_index_t index, const lash_map_simple_layer_item_t value); +lash_map_simple_layer_item_t lash_mapSimpleLayerPeek(lash_map_simple_layer_t *layer, const lash_game_map_index_t index); +lash_map_simple_t * lash_mapSimpleClip(lash_map_simple_t *clipmap, lash_map_simple_t *sourcemap, const unsigned int clip_x_radius, const unsigned int clip_y_radius, const lash_game_map_index_t clip_origin_index, enum lash_game_map_alignment clip_origin_alignment, int include_path_only); +int lash_mapSimpleGetSize(lash_map_simple_t *map); + +#endif // LASH_GAME_MAP_SIMPLE_H_ + + + +/** + * \fn lash_mapSimpleClip(lash_map_simple_t *clipmap, lash_map_simple_t *sourcemap, const unsigned int clip_x_radius, const unsigned int clip_y_radius, const lash_game_map_index_t clip_origin_index, enum lash_game_map_clip_alignment clip_origin_alignment, int include_path_only) + * + * \todo Support for defining other alignments from index (especially topleft). Currently it only calculates clip with index in center and in "radius" rectangle around. + * \todo Support for copying all layers, now it only copies the first (layer_path) + * \todo Support for copying (back) from clip to map +*/ diff --git a/lash_game_path_simple.c b/lash_game_path_simple.c @@ -0,0 +1,312 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "liblash/lash_tree3.h" +#include "liblashgame/lash_game_path_simple.h" +#include "liblashgame/lash_game_standard.h" + +/** + * \todo unitsize should be defined somewhere centrally. Map can be candidate + * \todo set obstaclelist on path init + * \warning the process step only checks for existence of existing spaces in the openlist, while theoretically a space can be shifted from openlist with nextstep without being added to the closedlist + * + */ + +int lash_pathSimpleInit() { + /*_lash_path_default_obstacles[0].val = 0; + _lash_path_default_obstacles[0].modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE; + _lash_path_default_obstacles[1].val = 1; + _lash_path_default_obstacles[1].modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL;*/ + _lash_path_default_obstacles = (lash_path_simple_obstacle_t *)malloc(sizeof(lash_path_simple_obstacle_t) * 2); + if (_lash_path_default_obstacles == NULL) + return 1; + + _lash_path_default_obstacles->val = 0; + _lash_path_default_obstacles->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE; + (_lash_path_default_obstacles + 1)->val = 1; + (_lash_path_default_obstacles + 1)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL; + + return 0; +} + +lash_path_simple_t * lash_pathSimpleNew(lash_path_simple_t *path, lash_map_simple_t *map, const lash_game_map_index_t offsetindex, const lash_game_map_index_t targetindex) { + unsigned int unitsize = 1; + unsigned int treecapacity = (unsigned int)*(map->w) * *(map->h) * 2; + + lash_game_coords_t offsetcoords; + lash_game_coords_t targetcoords; + + lash_indexToCartesian(&offsetcoords, map->w, map->h, &unitsize, &offsetindex); + lash_indexToCartesian(&targetcoords, map->w, map->h, &unitsize, &targetindex); + + path->w = map->w; + path->h = map->h; + path->target = targetindex; + path->source = offsetindex; + + // enough for the whole world if necessary, consider making a realloc routine for these + path->opentree = lash_treeInit(path->opentree, treecapacity); + if (path->opentree == NULL) + return NULL; + + path->closedtree = lash_treeInit(path->closedtree, treecapacity); + if (path->closedtree == NULL) + return NULL; + + path->spaces = (lash_path_simple_space_t*)malloc(sizeof(lash_path_simple_space_t) * treecapacity); + if (path->spaces == NULL) + return NULL; + + path->space_capacity = treecapacity; + path->space_count = 0; + + if (_lash_pathSimpleUpdateSpace(path, path->spaces, NULL, offsetindex, 0) == NULL) + return NULL; + + path->space_count = 1; + + lash_treePush(path->opentree, path->spaces, NULL); + + return path; +} + +lash_path_simple_space_t * _lash_pathSimpleAddSpace(lash_path_simple_t *path) { + + + if (path->space_count == path->space_capacity) { + printf("SPACE COUNT is not %d / %d", path->space_count, path->space_capacity); + return NULL; + } + + path->space_count++; + + return (path->spaces + path->space_count - 1); +} + +lash_path_simple_t * _lash_pathSimpleUpdateSpace(lash_path_simple_t *path, lash_path_simple_space_t *currentspace, lash_path_simple_space_t *parent, const lash_game_map_index_t currentindex, const unsigned int g) { + /// \todo check memory cap, increase if necessary + unsigned int unitsize = 1; + lash_game_coords_t targetcoords, currentcoords; + currentspace->g = g; + currentspace->parent = parent; + lash_indexToCartesian(&targetcoords, path->w, path->h, &unitsize, &path->target); + lash_indexToCartesian(&currentcoords, path->w, path->h, &unitsize, &currentindex); + currentspace->h = lash_getManhattanMagnitudeFromCartesian(targetcoords, currentcoords); + currentspace->f = (currentspace->h * 10) + currentspace->g; // f score + currentspace->index = currentindex; + return path; +} + +int _lash_pathSimpleClose(lash_path_simple_t *path, lash_path_simple_space_t *space) { + return lash_treePush(path->closedtree, space, NULL); +} + +/** + * \todo weighted movement calculations for semi-passable spaces + */ +unsigned int lash_pathSimpleStepProcess(lash_path_simple_t *path, lash_map_simple_t *map, lash_path_simple_space_t *centerspace, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount) { + int newx; + int newy; + unsigned int unitsize = 1; + unsigned int freespaces = 0; + lash_game_coords_t centercoords, newcoords; + + if (obstacleslist == NULL || obstaclescount == 0) { + obstacleslist = _lash_path_default_obstacles; + obstaclescount = LASH_GAME_PATH_SIMPLE_OBSTACLE_DEFAULT_COUNT; + } + + lash_indexToCartesian(&centercoords, map->w, map->h, &unitsize, (lash_game_map_index_t*)&centerspace->index); + + // close the current index + _lash_pathSimpleClose(path, centerspace); + + //printf("Processing index %u\n", centerspace->index); + + // loop through adjacent vertical spaces + for (newy = centercoords.y - 1; newy <= (int)(centercoords.y + 1); newy++) { + + // loop through adjacent horizontal spaces + for (newx = centercoords.x - 1; newx <= (int)(centercoords.x + 1); newx++) { + + //printf("x %u y %u ", newx, newy); + + // store the movement modifier + // this is currently only binary - passable or non passable + float modifier; + + // store the new space for editing + lash_path_simple_space_t *newspace; + + // newindex -1 means invalid index + lash_game_map_index_t newindex = -1; + + // initialize the score with diagonal movement + // change it further down if movement is straight + // the score is the weight of the movement from the path's startindex to current centerspace, plus this new movement + unsigned char newscore = centerspace->g + LASH_GAME_PATH_SIMPLE_SCORE_DIAGONAL; + + // if out of bounds then do nothing + if (newx < 0 || newx > *(map->w) - 1 || newy < 0 || newy > *(map->h) -1) { + //printf("(out of bounds)\n"); + continue; + } + + // lash_game_coords_t handle only unsigned values, so the negatives must be handled with local ints + newcoords.x = newx; + newcoords.y = newy; + + // find the index of the current adjacent space + lash_cartesianToIndex(&newindex, map->w, map->h, &unitsize, &newcoords); + //printf("i %u: ", (unsigned int)newindex); + + // modifier related + modifier = lash_pathSimpleCheckModifier(&(map->layer_path + newindex)->val, obstacleslist, obstaclescount); + // if not passable, do nothing with this space + if (modifier == 0.f) { + //printf("impassable\n"); + continue; + } + + // if the space is already in the closedlist, do nothing with this space + if (_lash_pathSimpleFindIndexInTree(path->closedtree, newindex)) { + //printf("closed\n"); + continue; + } + + // update the newscore if movement is straight + if (newcoords.y == centercoords.y) { + // if same square as center + // this should never be evaluated, as the current square should be on the closed list + if (newcoords.x == centercoords.x) { + continue; + } + // right of left + newscore = centerspace->g + LASH_GAME_PATH_SIMPLE_SCORE_STRAIGHT; + } else if (newcoords.x == centercoords.x) { + // up or down + newscore = centerspace->g + LASH_GAME_PATH_SIMPLE_SCORE_STRAIGHT; + } + + // if we made it this far, it means that the space should be evaluated + // that means process it for the openlist + newspace = _lash_pathSimpleFindIndexInTree(path->opentree, newindex); + + // if the space is not already in the openlist, add it and update it + if (newspace == NULL) { + newspace = _lash_pathSimpleAddSpace(path); + _lash_pathSimpleUpdateSpace(path, newspace, centerspace, newindex, newscore); + lash_treePush(path->opentree, newspace, NULL); + // if not update the existing space + // compare to the old score + // if old score is lower change back + } else { + lash_path_simple_space_t oldspace; + memcpy(&oldspace, newspace, sizeof(lash_path_simple_space_t)); + _lash_pathSimpleUpdateSpace(path, newspace, centerspace, newindex, newscore); + if (newspace->f > oldspace.f) + memcpy(newspace, &oldspace, sizeof(lash_path_simple_space_t)); + } + + //printf("score %u\n", newspace->f); + + freespaces++; + } + } + + return freespaces; +} + + +lash_path_simple_space_t * lash_pathSimpleNext(lash_path_simple_t *path, lash_path_simple_space_t **space) { + + if (path->opentree->count == 0) { + *space = NULL; + } + + lash_treeShift(path->opentree, (void*)space); + + return (lash_path_simple_space_t*)space; +} + +// 1.0 = full movement, 0.0 = impassable +float lash_pathSimpleCheckModifier(const lash_map_simple_layer_item_t *layeritem, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount) { + if (layeritem == NULL || obstacleslist == NULL || obstaclescount == 0) + return -1.0; + + int i; + for (i = 0; i < obstaclescount; i++) { + if (*layeritem == (obstacleslist+i)->val) + return (obstacleslist+i)->modifier / (float)LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE; + } + return -1.0; +} + +void lash_pathSimpleFree(lash_path_simple_t *path) { + + if (path->spaces != NULL) + free(path->spaces); + + if (path->opentree != NULL) + lash_treeFree(path->opentree); + + if (path->closedtree != NULL) + lash_treeFree(path->closedtree); + +} + +void lash_pathSimpleFinish() { + if (_lash_path_default_obstacles != NULL) + free(_lash_path_default_obstacles); +} + + +lash_path_simple_space_t * _lash_pathSimpleFindIndexInTree(lash_tree_t *tree, lash_game_map_index_t index) { + int i; + lash_path_simple_space_t *checkspace = NULL; + + if (tree == NULL) + return NULL; + + for (i = 0; i < tree->count; i++) { + checkspace = (lash_path_simple_space_t*)*(tree->item + i); + if (checkspace->index == index) + return checkspace; + } + + return NULL; +} + +int lash_pathSimpleCompileFreeSpaces(unsigned int **freeindices, const unsigned int freeindices_capacity, lash_map_simple_layer_t *sourcelayer, const unsigned int sourcelayer_count, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount) { + return lash_pathSimpleCompileMaxObstructedSpaces(freeindices, freeindices_capacity, sourcelayer, sourcelayer_count, obstacleslist, obstaclescount, 0.0); +} + +int lash_pathSimpleCompileMaxObstructedSpaces(unsigned int **freeindices, const unsigned int freeindices_capacity, lash_map_simple_layer_t *sourcelayer, const unsigned int sourcelayer_count, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount, float modifier_threshold) { + int i; + int freeindices_count = 0; + + + if (sourcelayer == NULL || freeindices == NULL) + return -1; + + if (obstacleslist == NULL || obstaclescount == 0) { + obstacleslist = _lash_path_default_obstacles; + obstaclescount = LASH_GAME_PATH_SIMPLE_OBSTACLE_DEFAULT_COUNT; + } + + + for (i = 0; i < sourcelayer_count; i++) { + if (freeindices_count == freeindices_capacity) + return freeindices_count; + + if (lash_pathSimpleCheckModifier(&(sourcelayer + i)->val, obstacleslist, obstaclescount) > modifier_threshold) { + *(*freeindices + freeindices_count) = i; + freeindices_count++; + } + + + } + + return freeindices_count; +} diff --git a/lash_game_path_simple.h b/lash_game_path_simple.h @@ -0,0 +1,83 @@ +#ifndef LASH_GAME_PATH_SIMPLE_H_ +#define LASH_GAME_PATH_SIMPLE_H_ + +#include "liblashgame/lash_game_standard.h" +#include "liblashgame/lash_game_map.h" +#include "liblash/lash_tree3.h" + +#define LASH_GAME_PATH_SIMPLE_SCORE_STRAIGHT 10 +#define LASH_GAME_PATH_SIMPLE_SCORE_DIAGONAL 14 + +// Defines amount of RESISTANCE +// Divide map value with modifier for resistance "NONE" = number to be multiplied by velocity +// Restistance NONE (192) = 192 / 192 = 1.0 of original movement +// Resistance TWOTHIRDS (64) = 64 / 192 = 0.3333 of original movement +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE 192 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_QUARTER 144 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_THIRD 128 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_HALF 96 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_TWOTHIRDS 64 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_THREEQUARTER 48 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL 0 + +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_DEFAULT_COUNT 2 + +typedef struct lash_path_simple_obstacle_t lash_path_simple_obstacle_t; + +struct lash_path_simple_obstacle_t { + lash_map_simple_layer_item_t val; + unsigned char modifier; +}; + +typedef struct lash_path_simple_space_t lash_path_simple_space_t; + +struct lash_path_simple_space_t { + lash_tree_key_t f; + unsigned char g; + unsigned int h; + lash_path_simple_space_t *parent; + lash_game_map_index_t index; +}; + +typedef struct lash_path_simple_t lash_path_simple_t; + +struct lash_path_simple_t { + unsigned int *w; + unsigned int *h; + lash_tree_t *opentree; + lash_tree_t *closedtree; + lash_path_simple_space_t *spaces; + unsigned int space_count; + unsigned int space_capacity; + lash_game_map_index_t source; + lash_game_map_index_t target; +}; + +//lash_path_simple_obstacle_t _lash_path_default_obstacles[2]; +lash_path_simple_obstacle_t *_lash_path_default_obstacles; + +#ifdef __cplusplus +extern "C" { +#endif + +int lash_pathSimpleInit(void); +void lash_pathSimpleFinish(void); +lash_path_simple_t * lash_pathSimpleNew(lash_path_simple_t *path, lash_map_simple_t *map, const lash_game_map_index_t offsetindex, const lash_game_map_index_t targetindex); +lash_path_simple_space_t * lash_pathSimpleNext(lash_path_simple_t *path, lash_path_simple_space_t **space); +float lash_pathSimpleCheckModifier(const lash_map_simple_layer_item_t *layeritem, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount); +unsigned int lash_pathSimpleStepProcess(lash_path_simple_t *path, lash_map_simple_t *map, lash_path_simple_space_t *center, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount); +void lash_pathSimpleFree(lash_path_simple_t *path); + +lash_path_simple_t * _lash_pathSimpleUpdateSpace(lash_path_simple_t *path, lash_path_simple_space_t *currentspace, lash_path_simple_space_t *parent, const lash_game_map_index_t currentindex, const unsigned int g); +lash_path_simple_space_t * _lash_pathSimpleAddSpace(lash_path_simple_t *path); +lash_path_simple_space_t * _lash_pathSimpleFindIndexInTree(lash_tree_t *tree, lash_game_map_index_t index); +int _lash_pathSimpleClose(lash_path_simple_t *path, lash_path_simple_space_t *space); + +int lash_pathSimpleCompileFreeSpaces(unsigned int **freeindices, const unsigned int freeindices_capacity, lash_map_simple_layer_t *sourcelayer, unsigned int sourcelayer_count, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount); +int lash_pathSimpleCompileMaxObstructedSpaces(unsigned int **freeindices, const unsigned int freeindices_capacity, lash_map_simple_layer_t *sourcelayer, unsigned int sourcelayer_count, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount, const float modifier_threshold); + +#ifdef __cplusplus +} +#endif + +#endif //LASH_GAME_PATH_SIMPLE_H_ diff --git a/lash_game_standard.c b/lash_game_standard.c @@ -0,0 +1,476 @@ +#include <stdlib.h> +#include <math.h> + +#include "lash_game_standard.h" + + +#define LASH_M_PI_DOUBLE (M_PI * 2) + +// http://stackoverflow.com/questions/4003232/how-to-code-a-modulo-operator-in-c-c-obj-c-that-handles-negative-numbers +// modulus must be handled differently for negatives + +unsigned char lash_getQuadrant(const float rads) { + int mod, quad; + mod = (int)floor(rads / M_PI_2); + quad = mod % 4; + + if (mod < 0) + if (quad != 0) + quad += 4; + + return quad + 1; +} + +unsigned char lash_getQuadrantFromCartesian(const int dx, const int dy) { + if (dx > 0) { + if (dy > 0) { + return 1; + } else { + return 4; + } + } else { + if (dy > 0) { + return 2; + } else { + return 3; + } + } + return 0; +} + + +enum lash_anglespan_compare lash_compareAngleSpan(float old_rad_min, float old_rad_max, float new_rad_min, float new_rad_max) { + double full_circle = 2 * M_PI; + + if (old_rad_max > full_circle) { + // if new angle is fully contained by the old, and the old angles are on each side of 2π + if (new_rad_min + full_circle < old_rad_max && new_rad_min + full_circle > old_rad_min) { + new_rad_min += full_circle; + new_rad_max += full_circle; + } + } else if (new_rad_max > full_circle && old_rad_max <= full_circle && old_rad_min < full_circle) { + // if the new angle are on each side of 2π, and the old min is inside the span + //if (new_rad_min < old_rad_max + full_circle && new_rad_min > old_rad_min + full_circle) { + old_rad_min += full_circle; + old_rad_max += full_circle; + //} + } + + enum lash_anglespan_compare result = LASH_ANGLESPAN_NONE; + if (new_rad_max < old_rad_max && new_rad_min > old_rad_min) { + result = LASH_ANGLESPAN_SPLIT; + } else { + if (new_rad_max >= old_rad_max && new_rad_min <= old_rad_max) + result = LASH_ANGLESPAN_MAX; + if (new_rad_min <= old_rad_min && new_rad_max >= old_rad_min) + result = result == LASH_ANGLESPAN_MAX ? LASH_ANGLESPAN_BOTH : LASH_ANGLESPAN_MIN; + } + return result; +} + +int lash_getContainedAngleOnly(const double x, const double y, const double m, const double w_container, const double h_container, const int buf_top, const int buf_right, const int buf_bottom, const int buf_left, double *angle_min, double *angle_max) { + double n = 0.f; + return lash_getContainedAngle(x, y, m, w_container, h_container, buf_top, buf_right, buf_bottom, buf_left, angle_min, angle_max, 0, &n, &n, &n, &n); +} + +int lash_getContainedAngle(const double x, const double y, const double m, const double w_container, const double h_container, const int buf_top, const int buf_right, const int buf_bottom, const int buf_left, double *angle_min, double *angle_max, const int include_dcoords, double *x_min, double *y_min, double *x_max, double *y_max) { + // any left + if (x - m < buf_left) { + // topleft + if (y - m < buf_top) { + double min_mod = M_PI; + double max_mod = 2 * M_PI; + *angle_min = min_mod + acos((x - buf_left) / m); + *angle_max = max_mod + asin((y - buf_top) / m); + if (include_dcoords) { + /* *x_min = buf_left; + *y_min = y + floor(sin(*angle_min - min_mod) * m); + *x_max = x + floor(cos(*angle_max - max_mod) * m); + *y_max = buf_top; */ + *x_min = buf_left; + *y_min = y + (sin(*angle_min - min_mod) * m); + *x_max = x + (cos(*angle_max - max_mod) * m); + *y_max = buf_top; + } + return 0; + // bottomleft + } else if (y + m > h_container - buf_bottom) { + double min_mod = 3 * M_PI_2; + double max_mod = 5 * M_PI_2; + *angle_min = min_mod + acos((x - buf_left) / m); + *angle_max = max_mod + asin((h_container - buf_bottom - y) / m); + if (include_dcoords) { + /* *x_min = x + floor(sin(*angle_min - min_mod) * m); + *y_min = h_container - buf_bottom; + *x_max = buf_left; + *y_max = y - floor(cos(*angle_max - max_mod) * m); */ + *x_min = x + (sin(*angle_min - min_mod) * m); + *y_min = h_container - buf_bottom; + *x_max = buf_left; + *y_max = y - (cos(*angle_max - max_mod) * m); + } + return 0; + } else { + // left + double tmp_angle = acos((x - buf_left) / m); + *angle_min = M_PI + tmp_angle; + *angle_max = (3 * M_PI) - tmp_angle; + if (include_dcoords) { + //int tmp_side = floor(sin(tmp_angle) * m); + int tmp_side = (sin(tmp_angle) * m); + *x_min = buf_left; + *y_min = y + tmp_side; + *x_max = buf_left; + *y_max = y - tmp_side; + } + return 0; + } + // any right + } else if (x + m > w_container - buf_right) { + // top right + if (y - m < buf_top) { + double min_mod = M_PI_2; + double max_mod = 3 * M_PI_2; + *angle_min = min_mod + acos((y - buf_top) / m); + *angle_max = max_mod + asin((w_container - buf_right - x) / m); + if (include_dcoords) { + /* *x_min = x - floor(sin(*angle_min - min_mod) * m); + *y_min = buf_top; + *x_max = w_container - buf_left; + *y_max = y + floor(cos(*angle_max - max_mod) * m); */ + *x_min = x - (sin(*angle_min - min_mod) * m); + *y_min = buf_top; + *x_max = w_container - buf_left; + *y_max = y + (cos(*angle_max - max_mod) * m); + } + return 0; + // bottom right + } else if (y + m > h_container - buf_bottom) { + //double min_mod = 0; + double max_mod = M_PI; + *angle_min = acos((w_container - buf_right - x) / m); + *angle_max = max_mod + asin((h_container - buf_bottom - y) / m); + if (include_dcoords) { + /* *x_min = w_container - buf_left; + *y_min = y - floor(sin(*angle_min) * m); + *x_max = x - floor(cos(*angle_max - max_mod) * m); + *y_max = h_container - buf_bottom;*/ + *x_min = w_container - buf_left; + *y_min = y - (sin(*angle_min) * m); + *x_max = x - (cos(*angle_max - max_mod) * m); + *y_max = h_container - buf_bottom; + } + return 0; + // right + } else { + //angle min has no modifier + //double tmp_angle = acos((h_container - buf_right - x) / m); + *angle_min = acos((w_container - buf_right - x) / m); + *angle_max = (2 * M_PI) - *angle_min; + if (include_dcoords) { + //int tmp_side = floor(sin(*angle_min) * m); + int tmp_side = (sin(*angle_min) * m); + *x_min = w_container - buf_right; + *y_min = y - tmp_side; + *x_max = w_container - buf_right; + *y_max = y + tmp_side; + + } + return 0; + } + // top (only) + } else if (y - m < buf_top) { + double tmp_angle = acos((y - buf_top) / m); + *angle_min = M_PI_2 + tmp_angle; + *angle_max = (5 * M_PI_2) - tmp_angle; + if (include_dcoords) { + //int tmp_side = floor(sin(tmp_angle) * m); + int tmp_side = (sin(tmp_angle) * m); + *x_min = x - tmp_side; + *y_min = buf_top; + *x_max = x + tmp_side; + *y_max = buf_top; + } + return 0; + // bottom (only) + } else if (y + m > h_container - buf_bottom) { + double tmp_angle = acos((h_container - buf_bottom - y) / m); + *angle_min = (3 * M_PI_2) + tmp_angle; + *angle_max = (7 * M_PI_2) - tmp_angle; + if (include_dcoords) { + //int tmp_side = floor(sin(tmp_angle) * m); + int tmp_side = (sin(tmp_angle) * m); + *x_min = x + tmp_side; + *y_min = h_container - buf_bottom; + *x_max = x - tmp_side; + *y_max = h_container - buf_bottom; + } + return 0; + } + + // default; no limit + *angle_min = 0.f; + *angle_max = 2 * M_PI; + if (include_dcoords) { + *x_min = h_container - buf_right; + *y_min = y; + *x_max = h_container - buf_right; + *y_max = y; + } + return 0; +} + +float lash_cartesianMagnitude(const int target_x, const int target_y, const int source_x, const int source_y) { + return sqrt(pow(target_x - source_x, 2) + pow(target_y - source_y, 2)); +} + +// self.h = abs((targetindex % map.w) - (index % map.w)) + abs(math.floor(targetindex / map.w) - math.floor(index / map.w)) +int lash_getManhattanMagnitudeFromCartesian(const lash_game_coords_t targetcoords, const lash_game_coords_t sourcecoords) { + //return abs((target_idx % *w) - (source_idx % *w)) + abs(floor(target_idx / *w) - floor(source_idx / *w)); + return abs(targetcoords.y - sourcecoords.y) + abs(targetcoords.x - sourcecoords.x); +} + +int lash_polarToCartesian(const float radians, const float radius, const int source_x, const int source_y, int *target_x, int *target_y) { + *target_x = source_x + floor(cos(radians) * radius); + *target_y = source_y + floor(sin(radians) * radius); + return 0; +} + +int lash_cartesianToPolar(const int source_x, const int source_y, const int target_x, const int target_y, float *radians, float *radius, const int inv_x, const int inv_y) { + + float tmp_radians; + + int x = target_x - source_x; + if (inv_x != 0) + x *= -1; + + int y = target_y - source_y; + if (inv_y != 0) + y *= -1; + + *radius = sqrt(pow(x, 2) + pow(y, 2)); + tmp_radians = atan2((float)y, (float)x); + if (tmp_radians < 0) + tmp_radians += 2 * M_PI; + + *radians = tmp_radians; + + return 0; +} + +int lash_cartesianToIndex(unsigned long int *index, const unsigned int *w, const unsigned int *h, unsigned int *unit_size, const lash_game_coords_cartesian_t *coords) { + + if (coords->x > *w - 1 || coords->y > *h - 1) + return 1; + + //*index = coords->x; + //*index += floor(coords->y * *w); + *index = coords->x / *unit_size; + *index += floor((coords->y * *w) / *unit_size); + + return 0; +} + +int lash_indexToCartesian(lash_game_coords_cartesian_t *coords, const unsigned int *w, const unsigned int *h, unsigned int *unit_size, const lash_game_map_index_t *index) { + + if ((*index) >= *w * *h) + return 1; + + if (*unit_size < 1) + *unit_size = 1; + + coords->x = (unsigned int)((*index % *w) * *unit_size); + coords->y = (unsigned int)(floor(*index / *w) * *unit_size); + + return 0; +} + +int lash_cartesianToFloat(lash_game_coords_float_t *coords_float, const unsigned int *w, const unsigned int *h, const lash_game_coords_cartesian_t *coords_cartesian) { + coords_float->x = (float)coords_cartesian->x / *w; + coords_float->y = (float)coords_cartesian->y / *h; + return 0; +} + +int lash_linearIntersect(const lash_game_line_t a, const lash_game_line_t b, lash_game_coords_float_t *coords) { + + coords->x = (b.c - a.c) / (a.m - b.m); + coords->y = (a.m * coords->x) + a.c; + if (isinf(coords->x) || isinf(coords->y)) + return 1; + return 0; + +} + +int lash_cartesianToLinear(const lash_game_coords_float_t src, const lash_game_coords_float_t target, lash_game_line_t *result) { + if (target.x == src.x) { + result->m = INFINITY; + result->c = INFINITY; + return 1; + } else if (target.y == src.y) { + result->m = NAN; + result->c = NAN; + return 1; + } else { + result->m = (target.y - src.y) / (float)(target.x - src.x); + result->c = ((-result->m) * src.x) + src.y; + } + return 0; +} + +float lash_distanceToRadians(const float distance, const float radius) { + return LASH_M_PI_DOUBLE * (distance / (LASH_M_PI_DOUBLE * radius)); +} + +float lash_normalizeRadians(float radians) { + char rotations = floor(radians / (2 * M_PI)); + if (rotations != 0) + radians -= LASH_M_PI_DOUBLE * rotations; + else if (radians < 0) + radians += LASH_M_PI_DOUBLE; + return radians; +} + +float lash_normalizeQuadrantRadians(float radians) { + float rotations = floor(radians / M_PI_2); + if (rotations != 0) + radians -= (float)M_PI_2 * rotations; + else if (radians < 0) + radians += M_PI_2 + (float)(M_PI_2 * rotations); + return radians; +} + +// calculates at the point of impact. +/// \todo resultquad calculation should resolve to being able to use resultquad for the objrad calculation below +void lash_collisionSurfaceDeflectSimple(float *objvel, float *objrad, const float surfacerad, float bounce) { + + + if (bounce < 0.f) + bounce = 0.0; + else if (bounce > 1.f) + bounce = 1.f; + + float resultquad; // the angle of impact + float direction; // the difference of objrad and surfacerad + float xvel, yvel; // the resulting velocities after bounce is calculated + float objradnormal, surfaceradnormal, objradquad, surfaceradquad, radmod; + char surfacequadrant, objquadrant; // quadrant the surface and object angles belong to + + objradnormal = lash_normalizeRadians(*objrad); + surfaceradnormal = lash_normalizeRadians(surfacerad); + + radmod = 0.f; // bounce angle + + surfacequadrant = floor(surfaceradnormal / M_PI_2); + objquadrant = floor(objradnormal / M_PI_2); + + objradquad = objradnormal - (objquadrant * (float)M_PI_2); // object rads normalized within quadrant + surfaceradquad = surfaceradnormal - (surfacequadrant * (float)M_PI_2); // surface rads normalized within quadrant + + if (objquadrant % 2 != surfacequadrant % 2) + direction = surfaceradquad + (M_PI_2 - objradquad); + else + direction = surfaceradquad - objradquad; + + + if (direction < 0.f) + resultquad = M_PI + direction; + else //if (direction < M_PI_2) + resultquad = M_PI - direction; + //else + //resultquad = direction; + + + if (direction < 0.f) + xvel = cos(-direction) * *objvel; + else + xvel = cos(direction) * *objvel; + + yvel = sin(direction) * *objvel * bounce; + + if (resultquad != M_PI_2) + radmod = atan(yvel / xvel); + + if (radmod < 0.f) + radmod = -radmod; + + if (direction < 0.f) + *objrad = *objrad + direction - radmod; + else if (direction > M_PI_2) + *objrad = *objrad - resultquad - radmod; + else + *objrad = *objrad + direction + radmod; + + *objvel = sqrt(pow(xvel, 2) + pow(yvel, 2)); + +} + + +// if want intersect coords, pass both as pointers, if NULL the coords are not resolved +char lash_collisionCheckCircleLine(const lash_game_coords_float_t circle_centre, const float circle_radius, const lash_game_line_t slope, lash_game_coords_float_t *intersect_coords_1, lash_game_coords_float_t *intersect_coords_2) { + return lash_collisionCircleLine(circle_centre, circle_radius, slope, intersect_coords_1, intersect_coords_2); +} + +char lash_collisionCircleLine(const lash_game_coords_float_t circle_centre, const float circle_radius, const lash_game_line_t slope, lash_game_coords_float_t *intersect_coords_1, lash_game_coords_float_t *intersect_coords_2) { + float a, b, c, discriminant; + char intersections = 0; + + // quadratic equation to resolve intersections from circle and line equation (substitute the line into circle, expand and collect equal terms) + // binomial: (m²+1)x²+2(mc−mq−p)x+(q²−r²+p²−2cq+c²)=0. + // discriminant: -2(mc−mq−p) +/- sqrt(pow(2(mc-mq-p), 2) - (4 * ((m*m)+1) * ((p*p)-(r*r)+(q*q)-(2*c*q)+(c*c)))) + // taken from http://math.stackexchange.com/questions/228841/how-do-i-calculate-the-intersections-of-a-straight-line-and-a-circle + a = (slope.m * slope.m) + 1; + b = 2 * ((slope.m * slope.c) - (slope.m * circle_centre.y) - circle_centre.x); + c = (circle_centre.x * circle_centre.x) + (circle_centre.y * circle_centre.y) - (2 * slope.c * circle_centre.y) + (slope.c * slope.c) - (circle_radius * circle_radius); + + discriminant = (b * b) - (4 * a * c); + if (discriminant > 0) + intersections = 2; + else if (discriminant == 0) + intersections = 1; + + if (intersections == 0) { + intersect_coords_1 = NULL; + intersect_coords_2 = NULL; + } else if (intersect_coords_1 != NULL && intersect_coords_2 != NULL) { + intersect_coords_1->x = (-b - sqrt(discriminant)) / (2 * a); + intersect_coords_1->y = (slope.m * intersect_coords_1->x) + slope.c; + if (intersections == 2) { + intersect_coords_2->x = (-b + sqrt(discriminant)) / (2 * a); + intersect_coords_2->y = (slope.m * intersect_coords_2->x) + slope.c; + } + } + + return intersections; +} + + +/* +/// \todo check if this is faster with circle/line intersect check +void lash_collisionCheckCircleLine(const lash_game_coords_float_t c_coords, const float c_r, const lash_game_coords_float_t l_coords_1, const lash_game_coords_float_t l_coords_2, float *intersect_perp) { + float l_reverse_vx, l_reverse_vy; + lash_game_line_t l_slope, l_reverse_slope; + lash_game_coords_float_t intersect_coords; + lash_cartesianToLinear(l_coords_1, l_coords_2, &l_slope); + reverse_vy = l_coords_1.x - l_coords_2.x; + reverse_vx = l_coords_1.y - l_coords_2.y; + l_reverse_slope.m = (reverse_vy / reverse_vx) * -1; + l_reverse_slope.c = c_coords.y - (l_reverse_slope.m * c_coords.x); + lash_linearIntersect(l_slope, l_reverse_slope, &intersect_coords); +} +*/ + +/* +int lash_isBigEndian() { + if (_lash_endian == -1) { + union { + uint32_t i; + char[4] c; + } bint = (0x01020304); + if (bint.c[0] == 1) + _lash_endian = 1; + else + _lash_endian = 0; + } + return _lash_endian; +} +*/ diff --git a/lash_game_standard.h b/lash_game_standard.h @@ -0,0 +1,157 @@ +#ifndef LASH_GAME_STANDARD_H_ +#define LASH_GAME_STANDARD_H_ + +#define LASH_GAME_GRAVITY_EARTH 9.8 +#define LASH_GAME_ATMOSPHERE_EARTH 101325 + +typedef struct lash_game_coords_t { + unsigned int x; + unsigned int y; +} lash_game_coords_t; + +typedef struct lash_game_coords_t lash_game_coords_cartesian_t; + +typedef struct lash_game_coords_float_t { + double x; + double y; +} lash_game_coords_float_t; + +typedef unsigned long int lash_game_map_index_t; + +typedef struct lash_game_line_t { + double m; + double c; +} lash_game_line_t; + +enum lash_anglespan_compare { + LASH_ANGLESPAN_NONE, + LASH_ANGLESPAN_MIN, + LASH_ANGLESPAN_MAX, + LASH_ANGLESPAN_BOTH, + LASH_ANGLESPAN_SPLIT +}; + +#ifdef __cplusplus +extern "C" { +#endif +unsigned char lash_getQuadrant(const float rads); +unsigned char lash_getQuadrantFromCartesian(const int dx, const int dy); +float lash_cartesianMagnitude(const int target_x, const int target_y, const int source_x, const int source_y); +float lash_getCartesianMagnitude(const int target_x, const int target_y, const int source_x, const int source_y); +int lash_cartesianToPolar(const int source_x, const int source_y, const int target_x, const int target_y, float *radians, float *radius, const int inv_x, const int inv_y); +int lash_polarToCartesian(const float radians, const float radius, const int source_x, const int source_y, int *target_x, int *target_y); +enum lash_anglespan_compare lash_compareAngleSpan(float old_rad_min, float old_rad_max, float new_rad_min, float new_rad_max); +int lash_getContainedAngle(const double x, const double y, const double m, const double w_container, const double h_container, const int buf_top, const int buf_right, const int buf_bottom, const int buf_left, double *angle_min, double *angle_max, const int include_dcoords, double *x_min, double *y_min, double *x_max, double *y_max); +int lash_getContainedAngleOnly(const double x, const double y, double m, const double w_container, const double h_container, const int buf_top, const int buf_right, const int buf_bottom, const int buf_left, double *angle_min, double *angle_max); +int lash_cartesianToIndex(unsigned long int *index, const unsigned int *w, const unsigned int *h, unsigned int *unit_size, const lash_game_coords_t *coords); +int lash_indexToCartesian(lash_game_coords_cartesian_t *coords, const unsigned int *w, const unsigned int *h, unsigned int *unit_size, const lash_game_map_index_t *index); +int lash_cartesianToFloat(lash_game_coords_float_t *coords_float, const unsigned int *w, const unsigned int *h, const lash_game_coords_cartesian_t *coords_cartesian); +int lash_getManhattanMagnitudeFromCartesian(const lash_game_coords_t targetcoords, const lash_game_coords_t sourcecoords); +int lash_linearIntersect(const lash_game_line_t a, const lash_game_line_t b, lash_game_coords_float_t *coords); +int lash_cartesianToLinear(const lash_game_coords_float_t src, const lash_game_coords_float_t target, lash_game_line_t *result); +float lash_distanceToRadians(const float distance, const float radius); +float lash_normalizeRadians(const float radians); +float lash_normalizeQuadrantRadians(float radians); +void lash_collisionSurfaceDeflectSimple(float *objvel, float *objrad, const float surfacerad, float bounce); +char lash_collisionCheckCircleLine(const lash_game_coords_float_t circle_centre, const float circle_radius, const lash_game_line_t slope, lash_game_coords_float_t *intersect_coords_1, lash_game_coords_float_t *intersect_coords_2); +char lash_collisionCircleLine(const lash_game_coords_float_t circle_centre, const float circle_radius, const lash_game_line_t slope, lash_game_coords_float_t *intersect_coords_1, lash_game_coords_float_t *intersect_coords_2); + +#ifdef __cplusplus +} +#endif + +#endif // LASH_GAME_STANDARD_H_ + + + +/** + * \file lash_game_standard.h + * \brief LASH Game movement angle routines + * + * \todo rename lash_game_map_index_t to lash_game_index_t, as it does not belong to map + */ + +/** + * \var enum lash_anglespan_compare + * \brief Specifies what action should be taken to transform a compared anglespan + * \sa lashCompareAngleSpan + */ + +/** + * \fn int lash_getContainedAngle(int x, int y, double m, int w_container, int h_container, int buf_top, int buf_right, int buf_bottom, int buf_left, double *angle_min, double *angle_max, int include_dcoords, int *x_min, int *y_min, int *x_max, int *y_max) + * \brief Determine movement angle contained within world bounds + * \param x the x position in the world + * \param y the y position in the world + * \param m the movement magnitude to check against + * \param w_container the width of the world + * \param h_container the height of the world + * \param buf_top max proximity to world top edge + * \param buf_right max proximity to world right edge + * \param buf_bottom max proximity to world bottom edge + * \param buf_left max proximity to world left edge + * \param *angle_min resulting minimum movement angle in radians + * \param *angle_max resulting maximum movement angle in radians + * \param include_dcoords whether or not to calculate the intersection between the extreme movement vectors and the game world edges + * \param *x_min resulting intersection point x coordinate of game world for the minimum movement angle radian + * \param *y_min resulting intersection point y coordinate of game world for the minimum movement angle radian + * \param *x_max resulting intersection point x coordinate of game world for the maximum movement angle radian + * \param *y_max resulting intersection point y coordinate of game world for the maximum movement angle radian + * + * From a position point and a movement magnitude, this function yields an angle span within which movement of the given magnitude will be kept within the world bounds. + * + * Optionally, the coordinates of the intersection points to the game world can also be calculated. In this case they will be stored in the variables passed in the last four parameters. + * These variables will be left unchanged if 0 is passed for include_dcoords + * + * \todo Return zero for both radians when movement in any case is out of world bounds (no vector is possible), or if position is out of bounds + * + */ + +/** + * \fn enum lash_anglespan_compare lash_compareAngleSpan(float old_rad_min, float old_rad_max, float new_rad_min, float new_rad_max) + * \brief Contiguous angle spans from two angles + * \param old_rad_min the old span minimum radian + * \param old_rad_min the old span maxumum radian + * \param old_rad_min the new span minimum radian + * \param old_rad_min the new span maximum radian + * + * Compares the span of two angles, and if they overlap returns which transformation should be made to reduce them to one contiguous span: + * - If the new span encloses the MINIMUM radian of the old span, then the old minimum should be set to the new minimum + * - If the new span encloses the MAXIMUM radian of the old span, then the old maximum should be set to the new maximum + * - If the new span encloses the WHOLE of the old span, then the old span should be replaced by the new span + * - If the new span is enclosed by the WHOLE of the old span, no change should occur + * - If the new span is outside of the old span, no change should occur + * + * \todo can never be LASH_ANGLESPAN_BOTH. BOTH should be enclosing the whole span, and should lead to deletion of the old span + * + */ + +/** + * \fn int lash_cartesianToIndex(unsigned long int *index, unsigned int *w, unsigned int *h, lash_game_coords_t *coords) + * \brief Get the linear index of a cartesian coordinate pair + * + * \param *index pointer to variable holding the resulting index + * \param *w the width of the coordinate system + * \param *h the height of the coordinate system + * \param *coords the coordinate pair to calculate + * + * If the coordinate pair is out of bounds, the variable the index parameter points to will be left unchanged, and the function will return 1 + * + * \see lashCartesianToIndex + * + */ + +/** + * \fn int lash_indexToCartesian(lash_game_coords_t *coords, unsigned int *w, unsigned int *h, unsigned long int *index) + * \brief Get the coordinate pair from a linear index + * + * \param *coords pointer to the struct the coordinate pair will be stored + * \param *w the width of the coordinate system + * \param *h the height of the coordinate system + * \param *index to calculate + * + * If the index is out of bounds, the variable the index parameter points to will be left unchanged, and the function will return 1 + * + * \see lashCartesianToIndex + * + */ + diff --git a/old/lash_game_path.c b/old/lash_game_path.c @@ -0,0 +1,228 @@ +#include <stdlib.h> +#include "liblashgame/lash_game_path.h" +#include "liblashgame/lash_game_standard.h" +#include "liblash/lash_tree.h" +#include "liblash/lash_tree_dump.h" +#include "liblashgame/lash_game_map.h" + +unsigned int _liblashgame_unitsize = 1; +unsigned int _path_simple_mem_increment_step = 0; +unsigned int _path_simple_mem_increments_amount = 0; + +lash_path_simple_t * lash_pathSimpleInit(lash_path_simple_t *path, lash_map_simple_t *map, const lash_game_map_index_t offsetindex, const lash_game_map_index_t targetindex) { + lash_game_coords_t offsetcoords; + lash_game_coords_t targetcoords; + lash_indexToCartesian(&offsetcoords, map->w, map->h, &_liblashgame_unitsize, &offsetindex); + lash_indexToCartesian(&targetcoords, map->w, map->h, &_liblashgame_unitsize, &targetindex); + _path_simple_mem_increment_step = (int)lash_getCartesianMagnitude(targetcoords.x, targetcoords.y, offsetcoords.x, offsetcoords.y) * 4; + path->w = map->w; + path->h = map->h; + path->target = targetindex; + path->source = offsetindex; + path->spaces_position = 0; + + path->spaces = (lash_path_simple_space_t*)malloc(sizeof(lash_path_simple_space_t) * (unsigned int)*(map->w) * *(map->h)); + if (path->spaces == NULL) + return NULL; + + path->opentree = lash_treeInit(path->opentree, (unsigned int)*(map->w) * *(map->h)); // enough for the whole world if necessary, consider making a realloc routine for this one too + if (path->opentree == NULL) + return NULL; + + path->closedtree = lash_treeInit(path->closedtree, (unsigned int)*(map->w) * *(map->h)); // enough for the whole world if necessary, consider making a realloc routine for this one too + if (path->closedtree == NULL) + return NULL; + + path->spacestree = lash_treeInit(path->spacestree, (unsigned int)*(map->w) * *(map->h)); + if (path->spacestree == NULL) + return NULL; + + lash_treeDumpInit(3); + lash_treeDumpAdd(path->opentree, "open"); + lash_treeDumpAdd(path->spacestree, "spaces"); + lash_treeDumpAdd(path->closedtree, "closed"); + + if (lash_pathSimpleUpdateSpace(path, NULL, NULL, offsetindex, 0) == NULL) + return NULL; + + lash_treePush(path->opentree, path->spaces->f, 0); + + return path; +} + +int _lash_pathSimpleMemInc(lash_path_simple_t *path) { + lash_path_simple_space_t *tmp_spaces; + + tmp_spaces = realloc(path->spaces, sizeof(lash_path_simple_space_t) * _path_simple_mem_increment_step * (_path_simple_mem_increments_amount + 1)); + + if (tmp_spaces == NULL) + return 1; + + path->spaces = tmp_spaces; + + return 0; +} + +lash_path_simple_space_t * lash_pathSimpleUpdateSpace(lash_path_simple_t *path, lash_path_simple_space_t *editspace, lash_path_simple_space_t *parent, const lash_game_map_index_t currentindex, const unsigned int g) { + /// \todo check memory cap, increase if necessary + lash_path_simple_space_t *currentspace; + lash_game_coords_t targetcoords, currentcoords; + + if (editspace != NULL) { + currentspace = editspace; + } else { + currentspace = (path->spaces + path->spaces_position); + currentspace->index = currentindex; + } + + currentspace->g = g; + currentspace->parent = parent; + lash_indexToCartesian(&targetcoords, path->w, path->h, &_liblashgame_unitsize, &path->target); + lash_indexToCartesian(&currentcoords, path->w, path->h, &_liblashgame_unitsize, &currentindex); + currentspace->h = lash_getManhattanMagnitudeFromCartesian(targetcoords, currentcoords); + currentspace->f = (currentspace->h * 10) + currentspace->g; + //lash_treePush(path->opentree, currentspace->f, currentindex); + + if (editspace == NULL) { + lash_treePush(path->spacestree, currentindex, path->spaces_position); + path->spaces_position++; + } + + return currentspace; +} + +//int lash_pathSimpleStep(lash_path_simple_space_t *parent) { +lash_path_simple_space_t * lash_pathSimpleStepProcess(lash_path_simple_t *path, lash_map_simple_t *map, lash_path_simple_space_t *center, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount) { + int i; + int newx; + int newy; + lash_game_coords_t centercoords, newcoords; + //lash_indexToCartesian(&centercoords, lash_path_simple_map->w, lash_path_simple_map->h, 1, &center->index); + lash_indexToCartesian(&centercoords, map->w, map->h, &_liblashgame_unitsize, (lash_game_map_index_t*)&center->index); + + // close the current index + lash_pathSimpleClose(path, center); + + //for (newcoords.y = centercoords.y - 1; newcoords.y <= centercoords.y + 1; newcoords.y++) { + for (newy = centercoords.y - 1; newy <= centercoords.y + 1; newy++) { + //for (newcoords.x = centercoords.x - 1; newcoords.x <= centercoords.x + 1; newcoords.x++) { + for (newx = centercoords.x - 1; newx <= centercoords.x + 1; newx++) { + lash_game_map_index_t newindex = -1; + unsigned char newscore = center->g + LASH_GAME_PATH_SIMPLE_SCORE_DIAGONAL; + float modifier; + + // if out of bounds + //if (newcoords.x < 0 || newcoords.x > *(map->w) - 1 || newcoords.y < 0 || newcoords.y > *(map->h) -1) + if (newx < 0 || newx > *(map->w) - 1 || newy < 0 || newy > *(map->h) -1) + continue; + + // coords handle only unsigned values, so the negatives must be handled with local ints + newcoords.x = newx; + newcoords.y = newy; + + lash_cartesianToIndex(&newindex, map->w, map->h, &_liblashgame_unitsize, &newcoords); + + // modifier related + modifier = lash_pathSimpleCheckModifier(&(map->layer_path + newindex)->val, obstacleslist, obstaclescount); + // if not passable + if (modifier == 0.f) + continue; + + // if the space already is created in memory, retrieve the index of it from the spaces index tree + int existingspacespos = -1; + int existingspacestreepos = lash_treeFindBySort(path->spacestree, newindex); + //int existingspacestreepos = lash_treeFindByLocal(path->spacestree, newindex); + + if (existingspacestreepos != -1) { + existingspacespos = *(path->spacestree->local + existingspacestreepos); + + // if the space already is on the closed list... + if (existingspacespos != -1) { + int existingclosedspacespos = lash_treeFindByLocal(path->closedtree, existingspacespos); + if (existingclosedspacespos != -1) + continue; + } + } + + if (newcoords.y == centercoords.y) { + // if same square as center + // this should never be evaluated, as the current square should be on the closed list + if (newcoords.x == centercoords.x) { + continue; + } + // if straight right of left + newscore = center->g + LASH_GAME_PATH_SIMPLE_SCORE_STRAIGHT; + } else if (newcoords.x == centercoords.x) { + // if straight up or down + newscore = center->g + LASH_GAME_PATH_SIMPLE_SCORE_STRAIGHT; + } + + if (existingspacespos != -1) { + unsigned int existingopenpos = lash_treeFindByLocal(path->opentree, existingspacespos); + + // if this index is NOT already in the openlist... (and space is not added either) + if (existingopenpos == -1) { + // add it to the openlist + lash_pathSimpleUpdateSpace(path, NULL, center, newindex, newscore); + //lash_treePush(path->opentree, newscore, path->spaces_position - 1); + lash_treePush(path->opentree, (path->spaces + path->spaces_position - 1)->f, path->spaces_position - 1); + } else { + if ((path->spaces + existingspacespos)->g > newscore) { + lash_pathSimpleUpdateSpace(path, (path->spaces + existingspacespos), center, 0, newscore); + lash_treeRemove(path->opentree, existingspacestreepos, NULL, NULL); + //lash_treePush(path->opentree, newscore, existingspacespos); + lash_treePush(path->opentree, (path->spaces + existingspacespos)->f, path->spaces_position - 1); + } + } + // if the space doesn't exist at all in the space list, it can't have been added to the openlist + } else { + lash_pathSimpleUpdateSpace(path, NULL, center, newindex, newscore); + //lash_treePush(path->opentree, newscore, path->spaces_position - 1); + + lash_treePush(path->opentree, (path->spaces + path->spaces_position - 1)->f, path->spaces_position - 1); + + } + } + } + + // remove the next step from the openlist and return it + // this is the position with the lowest f value + return lash_pathSimpleNext(path); +} + +int lash_pathSimpleClose(lash_path_simple_t *path, lash_path_simple_space_t *space) { + unsigned int spacepos = lash_treeFindBySort(path->spacestree, space->index); + return lash_treePush(path->closedtree, (long int)path->closedtree->position, (unsigned int)(space - path->spaces)); +} + +lash_path_simple_space_t * lash_pathSimpleNext(lash_path_simple_t *path) { + unsigned int nextstepindex; + long int nextstepf; + int i; + + if (lash_treeShift(path->opentree, &nextstepf, &nextstepindex) == -1) + return NULL; + + return path->spaces + nextstepindex; +} + +// 1.0 = full movement, 0.0 = impassable +float lash_pathSimpleCheckModifier(const lash_map_simple_layer_item_t *layeritem, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount) { + if (layeritem == NULL || obstacleslist == NULL || obstaclescount == 0) + return 1; + + int i; + for (i = 0; i < obstaclescount; i++) { + if (*layeritem == (obstacleslist+i)->val) + // should be done directly with the bits for speed + return (obstacleslist+i)->modifier / (float)LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE; + } + return 1; +} + +void lash_pathSimpleFree(lash_path_simple_t *path) { + free(path->opentree); + free(path->closedtree); + free(path->spacestree); + free(path->spaces); +} diff --git a/old/lash_game_path.h b/old/lash_game_path.h @@ -0,0 +1,196 @@ +#ifndef LASH_GAME_PATH_SIMPLE_H_ +#define LASH_GAME_PATH_SIMPLE_H_ + +#include "liblashgame/lash_game_standard.h" +#include "liblashgame/lash_game_map.h" +#include "liblash/lash_tree.h" + +#define LASH_GAME_PATH_SIMPLE_SCORE_STRAIGHT 10 +#define LASH_GAME_PATH_SIMPLE_SCORE_DIAGONAL 14 + +// Defines amount of resistance, not amount of movement +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE 192 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_QUARTER 144 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_THIRD 128 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_HALF 96 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_TWOTHIRDS 64 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_THREEQUARTER 48 +#define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL 0 + +typedef struct lash_path_simple_obstacle_t lash_path_simple_obstacle_t; + +struct lash_path_simple_obstacle_t { + lash_map_simple_layer_item_t val; + unsigned char modifier; +}; + +typedef struct lash_path_simple_space_t lash_path_simple_space_t; + +struct lash_path_simple_space_t { + unsigned char g; + unsigned int h; + unsigned int f; + lash_path_simple_space_t *parent; + lash_game_map_index_t index; +}; + +typedef struct lash_path_simple_t lash_path_simple_t; + +struct lash_path_simple_t { + unsigned int *w; + unsigned int *h; + //lash_path_simple_space_t *openlist; + //lash_path_simple_space_t *closedlist; + lash_path_simple_space_t *spaces; + lash_tree_t *opentree; + lash_tree_t *closedtree; + lash_tree_t *spacestree; + //unsigned int openlist_idx; + //unsigned int closedlist_idx; + unsigned int spaces_position; + lash_game_map_index_t source; + lash_game_map_index_t target; +}; + +//int lash_pathSimpleInit(const unsigned int *w, const unsigned int *h, const lash_game_map_index_t index_offset, const lash_game_map_index_t index_target); +lash_path_simple_t * lash_pathSimpleInit(lash_path_simple_t *path, lash_map_simple_t *map, const lash_game_map_index_t offsetindex, const lash_game_map_index_t targetindex); +int _lash_pathSimpleMemInc(lash_path_simple_t *path); +lash_path_simple_space_t * lash_pathSimpleUpdateSpace(lash_path_simple_t *path, lash_path_simple_space_t *editspace, lash_path_simple_space_t *parent, const lash_game_map_index_t currentindex, const unsigned int g); +//int lash_pathSimpleStep(lash_path_simple_space_t *parent); +lash_path_simple_space_t * lash_pathSimpleStepProcess(lash_path_simple_t *path, lash_map_simple_t *map, lash_path_simple_space_t *parent, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount); +lash_path_simple_space_t * lash_pathSimpleNext(lash_path_simple_t *path); +int lash_pathSimpleClose(lash_path_simple_t *path, lash_path_simple_space_t *space); +float lash_pathSimpleCheckModifier(const lash_map_simple_layer_item_t *layeritem, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount); +void lash_pathSimpleFree(lash_path_simple_t *path); + +#endif //LASH_GAME_PATH_SIMPLE_H_ + +/** + * \file lash_game_path.h + * \brief A* Pathfinder routine for tiled maps + * \todo Consider putting map and obstacles directly in path struct + * \todo Internal handling of target reached + * \todo Consider changing defines into enums + */ + +/** + * \struct lash_path_simple_t + * \brief The path object + * \var lash_path_simple_t::w + * World width + * \var lash_path_simple_t::h + * World height + * \var lash_path_simple_t::spaces + * Array of \ref lash_path_simple_space_t objects comprising the spaces used for path checking + * \var lash_path_simple_t::opentree + * Array of spaces adjacent to the spaces along the current path. Points to indices in the \ref lash_path_simple_t::spacestree array + * \var lash_path_simple_t::closedtree + * Array of chosen spaces. Points to indices in the \ref lash_path_simple_t::spacestree array + * \var lash_path_simple_t::spacestree + * Array of spaces used by the path processor + * \var lash_path_simple_t::spaces_position + * The current end position of the \ref lash_path_simple_t::spacestree array + * \var lash_path_simple_t::source + * Map index value of the start position + * \var lash_path_simple_t::target + * Map index value of the target position + */ + +/** + * \struct lash_path_simple_space_t + * \brief Path space + * \var lash_path_simple_space_t::g + * The score of reaching this space from offset + * \var lash_path_simple_space_t::g + * The score of reaching the target through this offset + * \var lash_path_simple_space_t::g + * The heuristic score from this space to the target + * \var lash_path_simple_space_t::parent + * The parent space; The space that was stepped through on the path's current route to reach this space + * \var lash_path_simple_space_t::index + * The map position of the space + */ + +/** + * \struct lash_path_simple_obstacle_t + * \brief Dictionary from map layer values to modifier factors + * \var lash_path_simple_obstacle_t::val + * The key value + * \var lash_path_simple_obstacle_t::modifier + * The modifier factor, in x / 192 + */ + +/** + * \fn int lash_pathSimpleClose(lash_path_simple_t *path, lash_path_simple_space_t *space) + * \brief Adds the specified space to the closedtree + * \param path The path to operate on + * \param space The space to add + * + * Returns the value of lashTreePush + * + * \todo Verify that space cannot be added if it already exists, and that return value is 1 if space cannot be added + * + */ + +/** + * \fn float lash_pathSimpleCheckModifier(const lash_map_simple_layer_item_t *layeritem, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount) + * \brief Returns the modifier factor for the specified map value + * \param layeritem Map value to check + * \param obstacleslist The list of modifier values to check against + * \param obstaclescount The size of the obstacles list + * + * \todo This routine currently only returns impassable for all map values that exist in the obstacles list + */ + +/** + * \fn lash_path_simple_space_t * lash_pathSimpleNext(lash_path_simple_t *path) + * \brief Returns the space with the lowest f value + * \param path The path to operate on + */ + +/** + * \fn lash_path_simple_space_t * lash_pathSimpleStepProcess(lash_path_simple_t *path, lash_map_simple_t *map, lash_path_simple_space_t *parent, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount) + * \brief Retrieves the next step towards the target + * \param path The path to operate on + * \param map The map data to use + * \param parent The current space + * \param obstacleslist Array of map values that modify movement + * \param obstaclescount Amount of values in obstacleslist + * + * Adds all passable, unclosed adjacent squares that are not already added to the openlist. + * Checks if the the current space is a faster step to reach each adjacent space, and updates the spaces accordingly. + * Retrieves the resulting space with the lowest f value, and returns a pointer to it. + * If NULL is returned, path cannot be found + * + * \sa lashPathSimpleNext + * \todo Implement movement modifiers + * \todo Verify return values for found target and no paths + */ + + +/** + * \fn lash_path_simple_t * lash_pathSimpleInit(lash_path_simple_t *path, lash_map_simple_t *map, const lash_game_map_index_t offsetindex, const lash_game_map_index_t targetindex) + * \brief Allocate memory and initialize members + * \param path The path to initialize + * \param map The map data to use + * \param offsetindex Where on the map to start + * \param targetindex Where on the map to end + * + * Initializes the path struct. + * Also sets a memory increase interval equal to 4 times the magnitude of the vector between offset and target. + * The binary tree sizes are initially set to this increase interval, and if will be expanded by the same amount if the capacity is exceeded. + * + */ + +/** + * \fn lash_path_simple_space_t * lash_pathSimpleUpdateSpace(lash_path_simple_t *path, lash_path_simple_space_t *editspace, lash_path_simple_space_t *parent, const lash_game_map_index_t currentindex, const unsigned int g) + * \brief Updates or adds a space to be checked + * \param path The path struct to operate on + * \param editspace If specified, a new space will not be added, but the values of the specified spaee will be updated instead + * \param parent The parent space of the current space + * \param currentindex The map position of the current space + * \param g The g value to set for the space + * + * + */ + diff --git a/old/tmp_collision.c b/old/tmp_collision.c @@ -0,0 +1,220 @@ +#ifndef COLLISION_H_INCLUDED +#define COLLISION_H_INCLUDED +#include <vector> +#include <cmath> + +float * get_limits(float *o_limit, float * o) { + + // only pairs! + if ((sizeof(o) / sizeof(float)) % 2 != 0) + return nullptr; + + // top, left, bottom, right - init to first point in list + + o_limit[0] = o[1]; + o_limit[1] = o[0]; + o_limit[2] = o[1]; + o_limit[3] = o[0]; + + + for (int i=0; i<sizeof(o); i+=2) { + if (o[i] < o_limit[1]) + o_limit[1] = o[i]; + else if (o[i] > o_limit[3]) + o_limit[3] = o[i]; + if (o[i+1] < o_limit[0]) + o_limit[0] = o[i+1]; + else if (o[i+1] > o_limit[2]) + o_limit[2] = o[i+1]; + } + + return o_limit; +} + +// note that after passing the array to a function it's reduced to a pointer, debugger won't print the list +// http://stackoverflow.com/questions/27212183/gdb-print-array-after-passing-to-function-only-prints-first-value-but-array-sti/27212252#27212252 + +// checks are done from o1 perspective +bool check_collision(float * o1, int o1_size, float * o2, int o2_size) { + + int collision_line = -1; // -1 = none, 0 = top, 1 = topleft, 2 = left [...] 7 = topright + + // arrays cannot be returned, so they must be passed by reference + // https://www.physicsforums.com/threads/inputting-an-array-in-to-a-function-or-returning-an-array-c.285625/ + // we want to modify the elements ... http://stackoverflow.com/questions/10007986/c-pass-an-array-by-reference + float o1_limit[4]; + get_limits(o1_limit, o1); + + float o2_limit[4]; + get_limits(o2_limit, o2); + + // first the crude check, to save processor if it can be ruled out this simply + + /* + // challenge: extra checks for either side needs to be added here to determine which direction + + if (o1_limit[0] <= o2_limit[2] && o1_limit[1] <= o2_limit[3]) + // o1 perspective this means collsion UPWARDS + collision_direction = 0; + else if (o1_limit[2] >= o2_limit[0] && o1_limit[1] <= o2_limit[3]) + collision_direction = 1; + else if (o1_limit[2] <= o2_limit[0] && o1_limit[3] >= o2_limit[1]) + collision_direction = 2; + else if (o1_limit[0] <= o2_limit[2] && o1_limit[3] >= o2_limit[1]) + collision_direction = 3; + */ + + // detect WHETHER the limit values intersect + /*if ((o1_limit[0] <= o2_limit[2] && o1_limit[1] <= o2_limit[3]) || + (o1_limit[2] >= o2_limit[0] && o1_limit[1] <= o2_limit[3]) || + (o1_limit[2] <= o2_limit[0] && o1_limit[3] >= o2_limit[1]) || + (o1_limit[0] >= o2_limit[2] && o1_limit[3] >= o2_limit[1])) + collision_line = 0;*/ + + + // thanks to this site for logic + // http://leetcode.com/2011/05/determine-if-two-rectangles-overlap.html + + if (!(o1_limit[0] > o2_limit[2] || o1_limit[1] > o2_limit[3] || o1_limit[2] < o2_limit[0] || o1_limit[3] < o2_limit[1])) + collision_line = 0; + + if (collision_line < 0) + return false; + + // fine grained inspection + + // for every o1 line, check if intersect of every o2 line is within bounds of o1 line + + // first find slope of each main line ((o1[i+3] - o1[i+1]) / (o1[i+2] / o1[i])) + + for (int i=0; i < (o1_size / sizeof(float)) - 1; i += 2) { + + float o1_x1, o1_x2, o1_y1, o1_y2; + if (i == 0) { + o1_x1 = o1[(o1_size / sizeof(float)) - 2]; + o1_y1 = o1[(o1_size / sizeof(float)) - 1]; + o1_x2 = o1[i]; + o1_y2 = o1[i+1]; + } else { + o1_x1 = o1[i-2]; + o1_y1 = o1[i-1]; + o1_x2 = o1[i]; + o1_y2 = o1[i+1]; + } + + float o1_slope = (o1_y2 - o1_y1) / (o1_x2 - o1_x1); + + for(int j = 0; j < (o2_size / sizeof(float)) - 1; j += 2) { + + float o2_x1, o2_x2, o2_y1, o2_y2; + if (j == 0) { + o2_x1 = o2[(o2_size / sizeof(float)) - 2]; + o2_y1 = o2[(o2_size / sizeof(float)) - 1]; + o2_x2 = o2[j]; + o2_y2 = o2[j+1]; + } else { + o2_x1 = o2[j-2]; + o2_y1 = o2[j-1]; + o2_x2 = o2[j]; + o2_y2 = o2[j+1]; + } + + float o2_slope = (o2_y2 - o2_y1) / (o2_x2 - o2_x1); + + // getting the o2 line slope, insert first inspection for PARALLELL lines! If lines are parallell, we need to check the endpoints to see if any part overlaps. if it does then we have collision. + // if it doesnt overlap it can still be within each other, but then one of the other lines in the shape will catch it! + // if it does then return here already + + // Hours and hours to try to figure out how to break the two xy equations into code, + // and then I find this totally different and super-simple solution by eliminating the Y totally from the picture. + // http://www.softwareandfinance.com/Visual_CPP/VCPP_Intersection_Two_lines_EndPoints.html + + // first the intercepts (where the lines cross the Y-axis) + + float intercept_o1 = o1_y1 - (o1_slope * o1_x1); + float intercept_o2 = o2_y1 - (o2_slope * o2_x1); + float intersect_x; + float intersect_y; + + if (o1_slope == o2_slope) { + if ((o1_x1 > o2_x1 && o1_x2 > o2_x1 && o1_x1 > o2_x2 && o1_x2 > o2_x2) || + (o1_x1 < o2_x1 && o1_x2 < o2_x1 && o1_x1 < o2_x2 && o1_x2 < o2_x2) || + intercept_o1 != intercept_o2) { + continue; + } else { + return true; + } + } + + // Formula for finding the intersections + + if (isinf(o1_slope)) { + intersect_x = o1_x1; + intersect_y = (o2_slope * intersect_x) + intercept_o2; + } else if (isinf(o2_slope)) { + intersect_x = o2_x1; + intersect_y = (o1_slope * intersect_x) + intercept_o1; + } else { + intersect_x = (intercept_o2 - intercept_o1) / (o1_slope - o2_slope); + intersect_y = (o1_slope * intersect_x) + intercept_o1; + } + // + // + // + // Check against o1 whether the point intersects + // + // int y2, y1, x2, x1 + // y2 = o1_y2 and y1 = o1_y1 if o1_y2 > o1_y1. If not then the other way around! + float y2, y1, x2, x1; + + if (o1_y2 > o1_y1) { + y2 = o1_y2; + y1 = o1_y1; + } else { + y2 = o1_y1; + y1 = o1_y2; + } + + if (o1_x2 > o1_x1) { + x2 = o1_x2; + x1 = o1_x1; + } else { + x2 = o1_x1; + x1 = o1_x2; + } + + if (y2 >= intersect_y && y1 <= intersect_y && x2 >= intersect_x && x1 <= intersect_x) { + if (o2_y2 > o2_y1) { + y2 = o2_y2; + y1 = o2_y1; + } else { + y2 = o2_y1; + y1 = o2_y2; + } + + if (o2_x2 > o2_x1) { + x2 = o2_x2; + x1 = o2_x1; + } else { + x2 = o2_x1; + x1 = o2_x2; + } + + if (y2 >= intersect_y && y1 <= intersect_y && x2 >= intersect_x && x1 <= intersect_x) { + //collision_line = i; + return true; + } + } + + // same for x2, x1... + // + // if y <= y2 && y >= y1 && x <= x2 && x <= x1 THEN we have collision. + + + } + } + + return false; +} + +#endif // COLLISION_H_INCLUDED diff --git a/tests/anglespan.c b/tests/anglespan.c @@ -0,0 +1,55 @@ +// test anglespan compare + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include "../lash_game_standard.h" + +int main(int argc, char *argv[]) { + + int test_count = 1000; + clock_t test_clock_total = 0.f; + + if (argc < 5) { + printf("Usage: %s old_rad_min old_rad_max new_rad_min new_rad_max\n\n", argv[0]); + return 1; + } + + float old_rad_min = atof(argv[1]); + float old_rad_max = atof(argv[2]); + float new_rad_min = atof(argv[3]); + float new_rad_max = atof(argv[4]); + + int i; + char *result_string; + + for (i = 0; i < test_count; i++) { + clock_t begin = clock(); + enum lash_anglespan_compare result = lash_compareAngleSpan(old_rad_min, old_rad_max, new_rad_min, new_rad_max); + test_clock_total += clock() - begin; + + switch(result) { + case LASH_ANGLESPAN_NONE: + result_string = "No change"; + break; + case LASH_ANGLESPAN_MAX: + result_string = "New max"; + break; + case LASH_ANGLESPAN_MIN: + result_string = "New min"; + break; + case LASH_ANGLESPAN_BOTH: + result_string = "New min and max"; + break; + case LASH_ANGLESPAN_SPLIT: + result_string = "Split"; + break; + default: + result_string = "(unknown result)"; + } + + } + printf("Old: min %f / max %f\nNew: min %f / max %f\nAction: %s\n", old_rad_min, old_rad_max, new_rad_min, new_rad_max, result_string); + printf("Avg execution time (from %d): %lu ticks @ %li pr sec = %.7f secs\n\n", test_count, (long)test_clock_total, CLOCKS_PER_SEC, ((double)test_clock_total / CLOCKS_PER_SEC) / test_count); + return 0; +} diff --git a/tests/cartesianfloat.c b/tests/cartesianfloat.c @@ -0,0 +1,26 @@ +// cartesian to float + +#include <stdio.h> +#include <stdlib.h> +#include "liblashgame/lash_game_standard.h" + +int main(int argc, char *argv[]) { + if (argc < 5) { + printf("Usage: %s x y w h", argv[0]); + return 1; + } + unsigned int w, h; + lash_game_coords_t coords_c; + lash_game_coords_float_t coords_f; + coords_c.x = atoi(argv[1]); + coords_c.y = atoi(argv[2]); + w = atoi(argv[3]); + h = atoi(argv[4]); + if (coords_c.x < 0 || coords_c.x > w || coords_c.y < 0 || coords_c.y > h) { + printf("X and Y must be within W and H\n"); + return 1; + } + lash_cartesianToFloat(&coords_f, &w, &h, &coords_c); + printf("Cartesian: x%d,y%d\nDimensions: w%d,h%d\nFloat x%f,y%f\n", coords_c.x, coords_c.y, w, h, coords_f.x, coords_f.y); + return 0; +} diff --git a/tests/cartesianindex.c b/tests/cartesianindex.c @@ -0,0 +1,45 @@ +// test of index to cartesian and back + +#include <stdio.h> +#include "../lash_game_standard.h" +#include <stdlib.h> + +int main(int argc, char **argv) { + lash_game_coords_t testcoords; + unsigned int unitsize = 1; + unsigned int w = 0; + unsigned int h = 0; + unsigned long int idx = 0; + unsigned int i = 0; + + if (argc < 5) { + printf("Usage: %s w h [x y|index] unitsize\n", *argv); + return 1; + } + + testcoords.x = 0; + testcoords.y = 0; + + w = atoi(*(argv+1)); + h = atoi(*(argv+2)); + + if (argc == 5) { + idx = atoi(*(argv+3)); + + } else if (argc == 6) { + testcoords.x = atoi(*(argv+3)); + testcoords.y = atoi(*(argv+4)); + i = 1; + } + + unitsize = atoi(*(argv+4+i)); + + if (i == 0) { + lash_indexToCartesian(&testcoords, &w, &h, &unitsize, &idx); + printf("Index %lu of w %u * h %u is x %u, y %u\n", idx, w, h, testcoords.x, testcoords.y); + } else { + lash_cartesianToIndex(&idx, &w, &h, &unitsize, &testcoords); + printf("x %u y %u of w %u * h %u is index %lu\n", testcoords.x, testcoords.y, w, h, idx); + } + return 0; +} diff --git a/tests/cartesianlinear.c b/tests/cartesianlinear.c @@ -0,0 +1,28 @@ +// test of cartesian to linear + +#include <stdio.h> +#include "../lash_game_standard.h" +#include <stdlib.h> + +int main(int argc, char **argv) { + lash_game_coords_float_t testtarget; + lash_game_coords_float_t testsource; + lash_game_line_t lineresult; + + if (argc < 5) { + printf("Usage: %s src_x src_y target_x target_y\n", *argv); + return 1; + } + + testsource.x = atof(*(argv+1)); + testsource.y = atof(*(argv+2)); + testtarget.x = atof(*(argv+3)); + testtarget.y = atof(*(argv+4)); + + + lash_cartesianToLinear(testsource, testtarget, &lineresult); + + printf("src %f,%f target %f,%f line m%f,c%f\n", testsource.x, testsource.y, testtarget.x, testtarget.y, lineresult.m, lineresult.c); + + return 0; +} diff --git a/tests/cartesianpolar.c b/tests/cartesianpolar.c @@ -0,0 +1,39 @@ +// cartesian to polar test + +#include "../lash_game_standard.h" +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) { + if (argc < 5 || (argc != 5 && argc < 7)) { + printf("Usage: %s src_x src_y target_x target_y [inv_x inv_y]\n", argv[0]); + return 1; + } + + int16_t target_x = atoi(argv[1]); + int16_t target_y = atoi(argv[2]); + int16_t src_x = atoi(argv[3]); + int16_t src_y = atoi(argv[4]); + float radians_result; + float radius_result; + int inv_x = 0; + int inv_y = 0; + + if (argc > 5) { + if (strcmp(argv[5], "0")) + inv_x = 1; + if (strcmp(argv[6], "0")) + inv_y = 1; + } + + lash_cartesianToPolar(src_x, src_y, target_x, target_y, &radians_result, &radius_result, inv_x, inv_y); + + char *inv_x_str = inv_x ? "Yes" : "No"; + char *inv_y_str = inv_y ? "Yes" : "No"; + + printf("Src: x%d,y%d\nTarget: x%d,y%d\nInverse X: %s\nInverse Y: %s\nRadians: %f\nRadius: %f\n", src_x, src_y, target_x, target_y, inv_x_str, inv_y_str, radians_result, radius_result); + + + return 0; +} diff --git a/tests/circleline.c b/tests/circleline.c @@ -0,0 +1,55 @@ +// test circle line intersect + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include "../lash_game_standard.h" + +int main(int argc, char *argv[]) { + + int i; + int warmup_count = 100; + int test_count = 10000; + int test_control_count = 0; + clock_t time_test_total = 0; + clock_t time_test_begin = 0; + + if (argc < 6) { + printf("Usage: %s circle_x circle_y circle_radius line_m line_c\n", argv[0]); + return 1; + } + + lash_game_coords_float_t c_c; + lash_game_line_t l; + float c_r; + lash_game_coords_float_t i1, i2; + char ic; + + c_c.x = atof(argv[1]); + c_c.y = atof(argv[2]); + c_r = atof(argv[3]); + l.m = atof(argv[4]); + l.c = atof(argv[5]); + + for (i = 0; i < warmup_count; i++) + ic = lash_collisionCheckCircleLine(c_c, c_r, l, &i1, &i2); + + for (i = 0; i < test_count; i++) { + time_test_begin = clock(); + ic = lash_collisionCheckCircleLine(c_c, c_r, l, &i1, &i2); + time_test_total += clock() - time_test_begin; + test_control_count ++; + } + + printf("Intersection count: %d\n", ic); + if (ic > 0) { + printf("Intersection 1: x%f,y%f\n", i1.x, i1.y); + if (ic == 2) { + printf("Intersection 2: x%f,y%f\n", i2.x, i2.y); + } + } + + printf("Average execution time: %2.0f (%10.7f secs)\n", (float)(time_test_total / test_count), (time_test_total / (float)test_count) / (float)CLOCKS_PER_SEC); + + return 0; +} diff --git a/tests/containedangle.c b/tests/containedangle.c @@ -0,0 +1,57 @@ +// test contained angle + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <time.h> +#include <math.h> +#include "../lash_game_standard.h" + +int main(int argc, char *argv[]) { + + int test_count = 1000; + clock_t test_clock_total = 0.f; + + if (argc < 10) { + printf("Usage: %s x y magnitude world_width world_height buffer_top buffer_right buffer_bottom buffer_left\n\n", argv[0]); + return 1; + } + //int x = atoi(argv[1]); + //int y = atoi(argv[2]); + double x = atof(argv[1]); + double y = atof(argv[2]); + double m = atof(argv[3]); + //int w_container = atoi(argv[4]); + //int h_container = atoi(argv[5]); + double w_container = atoi(argv[4]); + double h_container = atoi(argv[5]); + int buf_top = atoi(argv[6]); + int buf_right = atoi(argv[7]); + int buf_bottom = atoi(argv[8]); + int buf_left = atoi(argv[9]); + + double angle_min = -1.f; + double angle_max = -1.f; + //int x_min = -1; + //int y_min = -1; + //int x_max = -1; + //int y_max = -1; + double x_min = -1.f; + double y_min = -1.f; + double x_max = -1.f; + double y_max = -1.f; + + int i; + + for (i = 0; i < test_count; i++) { + clock_t begin = clock(); + lash_getContainedAngle(x, y, m, w_container, h_container, buf_top, buf_right, buf_bottom, buf_left, &angle_min, &angle_max, 1, &x_min, &y_min, &x_max, &y_max); + clock_t end = clock(); + test_clock_total += end - begin; + } + //printf("World size: %d,%d\nPosition: %d,%d\nBuffers: %d,%d,%d,%d\nAngle min: %f (edge at %d,%d)\nAngle max: %.2f (edge at %d,%d)\n", w_container, h_container, x, y, buf_top, buf_right, buf_bottom, buf_left, angle_min, x_min, y_min, angle_max, x_max, y_max); + printf("World size: %f,%f\nPosition: %f,%f\nBuffers: %d,%d,%d,%d\nAngle min: %f (edge at %f,%f)\nAngle max: %.2f (edge at %f,%f)\n", w_container, h_container, x, y, buf_top, buf_right, buf_bottom, buf_left, angle_min, x_min, y_min, angle_max, x_max, y_max); + printf("Avg execution time (from %d): %lu ticks @ %li pr sec = %.7f secs\n\n", test_count, (long)test_clock_total, CLOCKS_PER_SEC, ((double)test_clock_total / CLOCKS_PER_SEC) / test_count); + + return 0; +} diff --git a/tests/findpath.c b/tests/findpath.c @@ -0,0 +1,129 @@ +// test the pathfinder +// this test should be split up for the add space and other individual items + + +#include <stdlib.h> +#include <stdio.h> +#include <time.h> +#include <string.h> +#include "liblashgame/lash_game_path_simple.h" +#include "liblashgame/lash_game_map.h" +#include "liblashgame/lash_game_standard.h" +#include "liblash/lash_tree3_dump.h" + +// segfault if input formats with commas aren't right +// the y coords should be checked for valid return from strtok before atoi +// does not check bounds of coords + +unsigned int _unitsize = 1; + + +void dumpmappathlayer(lash_map_simple_t *map) { + lash_game_coords_t tmpcoords; + lash_game_map_index_t tmpidx; + for (tmpcoords.y = 0; tmpcoords.y < *map->h; tmpcoords.y++) { + for (tmpcoords.x = 0; tmpcoords.x < *map->w; tmpcoords.x++) { + lash_cartesianToIndex(&tmpidx, map->w, map->h, &_unitsize, &tmpcoords); + printf("%02i ", (int)lash_mapSimpleLayerPeek(map->layer_path, tmpidx)); + } + printf("\n"); + } + printf("\n"); +} + +int main(int argc, char *argv[]) { + if (argc < 5) { + printf("Usage: %s world_width world_height startx,starty targetx,targety obstacleindexval[,obstacleoindexval[...]] [obstaclex,obstacley,obstacleitemval [obstaclex,obstacley,obstacleitemval ...]]\n", argv[0]); + return 1; + } + + int i; + + lash_game_coords_t offset_coords; + lash_game_coords_t target_coords; + lash_game_map_index_t offset_idx; + lash_game_map_index_t target_idx; + lash_game_map_index_t *obstacles; + + unsigned int w = atoi(argv[1]); + unsigned int h = atoi(argv[2]); + + offset_coords.x = atoi(strtok(argv[3], ",")); + offset_coords.y = atoi(strtok(NULL, ",")); + lash_cartesianToIndex(&offset_idx, &w, &h, &_unitsize, &offset_coords); + + target_coords.x = atoi(strtok(argv[4], ",")); + target_coords.y = atoi(strtok(NULL, ",")); + lash_cartesianToIndex(&target_idx, &w, &h, &_unitsize, &target_coords); + + printf("World: w%d x h%d\nOffset: x%d,y%d (idx %d)\nTarget: x%d,y%d (idx %d)\n", w, h, offset_coords.x, offset_coords.y, (int)offset_idx, target_coords.x, target_coords.y, (int)target_idx); + printf("Obstacle definitions: "); + + int obstaclemastercount = 0; + char *tmpobstaclemastersource = (char*)malloc(strlen(argv[5])); + strcpy(tmpobstaclemastersource, argv[5]); + char *tmpobstaclemaster = strtok(tmpobstaclemastersource, ","); + while (tmpobstaclemaster != NULL) { + obstaclemastercount++; + tmpobstaclemaster = strtok(NULL, ","); + } + + lash_path_simple_obstacle_t *obstaclemasterlist = (lash_path_simple_obstacle_t*)malloc(sizeof(lash_path_simple_obstacle_t) * obstaclemastercount); + i=0; + strcpy(tmpobstaclemastersource, argv[5]); + char *tmpobstaclemaster2 = strtok(tmpobstaclemastersource, ","); + while (tmpobstaclemaster2 != NULL) { + (obstaclemasterlist + i)->val = atoi(tmpobstaclemaster2); + (obstaclemasterlist + i)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL; + printf("%d ", (obstaclemasterlist + i)->val); + tmpobstaclemaster2 = strtok(NULL, ","); + i++; + } + free(tmpobstaclemastersource); + printf("\n"); + + + lash_map_simple_t map; + lash_mapSimpleInit(&map, &w, &h); + + if (argc > 6) { + obstacles = (lash_game_map_index_t*)malloc(sizeof(lash_game_map_index_t) * (argc - 6)); + + for (i = 0; i < argc - 6; i++) { + lash_game_coords_t obstacle_coords; + lash_map_simple_layer_item_t obstacleval; + obstacle_coords.x = atoi(strtok(argv[i + 6], ",")); + obstacle_coords.y = atoi(strtok(NULL, ",")); + obstacleval = atoi(strtok(NULL, ",")); + lash_cartesianToIndex((obstacles + i), &w, &h, &_unitsize, &obstacle_coords); + lash_mapSimpleLayerPoke(map.layer_path, *(obstacles +i), obstacleval); + printf("Obstacle #%d: x%d,y%d (idx %d) of type %d\n", i + 1, obstacle_coords.x, obstacle_coords.y, (int)*(obstacles + i), obstacleval); + } + } + + lash_path_simple_t path; + lash_path_simple_space_t *space; + + lash_pathSimpleNew(&path, &map, offset_idx, target_idx); + + lash_treeDumpInit(1); + lash_treeDumpAdd(path.closedtree, "closedtree"); + + lash_pathSimpleNext(&path, &space); + + printf("Map path layer dump:\n"); + dumpmappathlayer(&map); + printf("---\nTrying step...\n"); + i = 0; + + while (space->index != path.target) { + + printf("Step %d with opentree index %p spaceindex %d target %d\n", ++i, *path.opentree->key, (int)space->index, (int)path.target); + lash_pathSimpleStepProcess(&path, &map, space, obstaclemasterlist, obstaclemastercount); + lash_pathSimpleNext(&path, &space); + if (space == NULL) + break; + } + + return 0; +} diff --git a/tests/getfreespace.c b/tests/getfreespace.c @@ -0,0 +1,64 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "liblashgame/lash_game_path_simple.h" +#include "liblashgame/lash_game_map.h" + +#include "common.h" + +int main() { + + int i; + + unsigned int w = 10; + unsigned int h = 10; + + int freespacecount = 0; + + lash_map_simple_t map; + + lash_path_simple_obstacle_t *obstacles; + unsigned char obstaclecount; + + unsigned int *indices; + + if (lash_mapSimpleInit(&map, &w, &h) == NULL) + return 1; + + fillMapRandom(&map, 3); + dumpMapPathLayer(&map, 1, -1, -1, -1); + + obstacles = (lash_path_simple_obstacle_t*)malloc(sizeof(lash_path_simple_obstacle_t) * 3); + if (obstacles == NULL) + return 1; + + obstacles->val = 0; + obstacles->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE; + (obstacles+1)->val = 1; + (obstacles+1)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL; + (obstacles+2)->val = 2; + (obstacles+2)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_HALF; + + obstaclecount = 3; + + indices = (unsigned int*)malloc(sizeof(unsigned int) * *(map.w) * *(map.h)); + if (indices == NULL) { + if (obstacles != NULL) + free(obstacles); + return 1; + } + + freespacecount = lash_pathSimpleCompileFreeSpaces(&indices, *(map.w) * *(map.h), map.layer_path, *(map.w) * *(map.h), obstacles, obstaclecount); + + printf("Found %d free spaces: ", freespacecount); + + for (i = 0; i < freespacecount; i++) { + printf("%02d ", *(indices + i)); + } + printf("\n"); + + free(indices); + free(obstacles); + + return 0; +} diff --git a/tests/getquadrant.c b/tests/getquadrant.c @@ -0,0 +1,15 @@ +// getquadrant + +#include "../lash_game_standard.h" +#include <stdlib.h> +#include <stdio.h> + +int main(int argc, char *argv[]) { + if (argc < 2) { + printf("Usage: %s rads\n", argv[0]); + return 1; + } + + printf("%d\n", lash_getQuadrant(atof(argv[1]))); + return 0; +} diff --git a/tests/include/common.c b/tests/include/common.c @@ -0,0 +1,42 @@ +#include <stdlib.h> +#include <stdio.h> +#include <time.h> + +#include "liblashgame/lash_game_map.h" + +#include "common.h" + +void fillMapRandom(lash_map_simple_t *map, lash_map_simple_layer_item_t max_value) { + int i; + time_t t; + + srand((unsigned) time(&t)); + + for (i = 0; i < *map->w * *map->h; i++) { + (map->layer_path + i)->val = rand() % max_value; + } +} + +void dumpMapPathLayer(lash_map_simple_t *map, unsigned int unitsize, int start, int target, int position) { + + + lash_game_coords_t tmpcoords; + lash_game_map_index_t tmpidx; + for (tmpcoords.y = 0; tmpcoords.y < *map->h; tmpcoords.y++) { + for (tmpcoords.x = 0; tmpcoords.x < *map->w; tmpcoords.x++) { + lash_cartesianToIndex(&tmpidx, map->w, map->h, &unitsize, &tmpcoords); + if (tmpidx == start) { + printf("XX "); + } else if (tmpidx == target) { + printf("-- "); + } else if (tmpidx == position) { + printf("?? "); + } else { + printf("%02i ", (int)lash_mapSimpleLayerPeek(map->layer_path, tmpidx)); + } + } + printf("\n"); + } + printf("\n"); + fflush(stdout); +} diff --git a/tests/include/common.h b/tests/include/common.h @@ -0,0 +1,7 @@ +#ifndef LASH_GAME_TESTS_COMMON_H_ +#define LASH_GAME_TESTS_COMMON_H_ + +void fillMapRandom(lash_map_simple_t *map, lash_map_simple_layer_item_t max_value); +void dumpMapPathLayer(lash_map_simple_t *map, unsigned int unitsize, int start, int target, int position); + +#endif // LASH_GAME_TESTS_COMMON_H_ diff --git a/tests/linear.c b/tests/linear.c @@ -0,0 +1,74 @@ +// function draft for meeting point of two lines + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include "../lash_game_standard.h" + + +int main(int argc, char *argv[]) { + + int i; + unsigned short test_count = 100; + clock_t test_clock_total_linear = 0.f; + clock_t test_clock_total_intersect = 0.f; + clock_t test_clock_begin = 0.f; + + if (argc < 9) { + printf("Usage: %s src1_x src1_y target1_x target1_y src2_x src2_y target2_x target2_y\n", argv[0]); + return 1; + } + + int src1_x = atoi(argv[1]); + int src1_y = atoi(argv[2]); + int target1_x = atoi(argv[3]); + int target1_y = atoi(argv[4]); + int src2_x = atoi(argv[5]); + int src2_y = atoi(argv[6]); + int target2_x = atoi(argv[7]); + int target2_y = atoi(argv[8]); + + lash_game_coords_float_t src1_f; + lash_game_coords_float_t src2_f; + lash_game_coords_float_t target1_f; + lash_game_coords_float_t target2_f; + lash_game_line_t line1; + lash_game_line_t line2; + lash_game_coords_float_t result; + + int nointersect = 1; + + src1_f.x = (float)src1_x; + src1_f.y = (float)src1_y; + src2_f.x = (float)src2_x; + src2_f.y = (float)src2_y; + target1_f.x = (float)target1_x; + target1_f.y = (float)target1_y; + target2_f.x = (float)target2_x; + target2_f.y = (float)target2_y; + + + for (i=0; i<test_count; i++) { + test_clock_begin = clock(); + lash_cartesianToLinear(src1_f, target1_f, &line1); + test_clock_total_linear += clock() - test_clock_begin; + } + + lash_cartesianToLinear(src2_f, target2_f, &line2); + + for (i=0; i<test_count; i++) { + test_clock_begin = clock(); + nointersect = lash_linearIntersect(line1, line2, &result); + test_clock_total_intersect += clock() - test_clock_begin; + } + + printf("Line 1: Src x%d,y%d - Target: x%d,y%d (Variable: %f, Const: %f)\n", src1_x, src1_y, target1_x, target1_y, line1.m, line1.c); + printf("Line 2: Src x%d,y%d - Target: x%d,y%d (Variable: %f, Const: %f)\n", src2_x, src2_y, target2_x, target2_y, line2.m, line2.c); + if (nointersect) + printf("No intersect point\n"); + else + printf("Intersect point x%f,y%f\n", result.x, result.y); + printf("Total time linear: %lu ticks @ %li pr sec = %.7f secs\n", (long)(test_clock_total_linear / (float)test_count), CLOCKS_PER_SEC, (double)((test_clock_total_linear / (float)test_count) / CLOCKS_PER_SEC)); + printf("Total time intersect: %lu ticks @ %li pr sec = %.7f secs\n\n", (long)(test_clock_total_intersect / (float)test_count), CLOCKS_PER_SEC, (double)((test_clock_total_intersect / (float)test_count) / CLOCKS_PER_SEC)); + return 0; +} diff --git a/tests/log.txt b/tests/log.txt @@ -0,0 +1,2598 @@ +Width 50 Height 50 index 1731 radius -1 target 646 +00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 01 00 00 00 01 01 00 01 00 01 01 00 00 00 00 00 01 01 01 01 00 01 01 00 01 01 01 01 01 00 01 00 00 01 +01 01 00 01 00 00 01 01 00 01 01 01 00 00 00 01 00 00 00 01 01 01 00 00 01 01 00 00 01 00 01 00 01 01 00 01 00 01 00 00 00 00 01 00 00 00 01 00 00 01 +01 01 01 01 00 00 00 00 00 00 01 01 00 00 00 00 00 00 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 00 00 00 00 01 01 00 01 00 01 01 00 00 00 00 00 01 +01 01 01 01 00 00 00 00 00 00 01 01 01 00 00 01 00 00 00 01 01 01 01 00 01 00 00 01 00 01 00 01 00 00 01 00 00 01 01 00 01 00 01 00 00 01 00 01 00 00 +00 01 00 00 01 01 00 00 00 00 01 00 00 01 00 01 00 00 00 01 00 00 01 00 00 00 01 00 01 01 01 01 00 01 01 00 00 01 00 00 00 01 00 00 00 01 01 00 01 01 +01 00 01 01 00 00 01 01 00 00 01 01 01 01 00 01 01 00 00 01 00 00 00 01 00 01 00 01 01 01 01 01 01 00 00 01 00 01 01 01 01 00 00 00 01 01 01 01 01 00 +00 00 00 01 01 01 00 01 00 01 00 01 00 00 00 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 00 01 00 01 00 01 00 00 00 00 00 01 00 00 01 00 01 00 00 00 +01 00 01 01 00 00 01 01 00 00 01 01 00 00 00 00 01 00 01 00 00 01 01 00 01 00 00 00 00 01 01 01 01 00 01 01 00 00 00 00 01 01 01 01 01 01 01 01 01 00 +01 00 01 00 00 01 00 01 01 00 00 00 00 01 00 01 00 00 01 00 01 00 01 00 01 01 00 01 00 01 01 01 01 01 01 00 00 01 01 01 01 01 00 01 00 00 00 00 01 00 +00 00 00 01 00 00 00 00 01 00 00 00 01 01 01 00 01 01 01 00 01 01 01 01 00 01 01 01 01 00 01 01 00 01 01 01 01 01 01 00 00 01 01 01 01 00 00 00 00 01 +01 01 00 00 00 01 00 01 00 01 00 01 01 00 00 00 01 00 01 01 00 01 00 01 01 01 00 01 00 00 00 01 01 01 01 01 00 01 00 00 01 00 01 00 01 01 00 00 01 01 +01 00 01 00 01 00 01 01 01 01 01 01 00 00 00 00 01 00 01 00 00 00 00 01 00 01 01 00 00 00 00 01 00 01 01 00 01 01 01 00 00 01 01 01 01 00 01 01 00 00 +01 01 01 01 00 01 01 01 00 01 00 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 01 01 01 00 00 00 01 01 00 01 00 01 01 00 00 01 00 00 01 01 00 00 01 01 +00 01 01 01 01 01 01 00 01 01 00 01 01 01 00 01 01 00 00 00 01 00 01 01 01 00 01 01 00 00 01 00 00 00 01 01 01 01 01 00 00 00 01 01 01 01 01 00 00 01 +00 01 00 01 00 01 00 01 00 00 00 01 01 00 01 00 01 01 01 00 01 01 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 01 01 01 01 00 00 01 00 00 00 01 00 +01 00 01 01 01 00 01 00 00 00 00 00 01 00 01 01 00 00 00 01 01 01 01 01 01 00 01 01 01 00 01 00 01 01 01 00 01 01 00 00 01 01 00 00 01 01 01 01 01 01 +00 00 00 01 00 01 00 01 01 01 00 00 01 01 01 00 01 01 01 00 01 00 01 01 00 00 00 00 01 00 01 01 00 00 01 00 01 01 00 00 00 00 01 01 01 00 01 00 01 01 +00 00 01 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 01 00 01 00 01 00 01 00 00 00 01 01 01 01 00 00 01 00 00 01 00 00 00 00 01 00 01 00 01 01 +01 00 01 00 01 00 00 00 01 00 00 00 01 01 01 00 00 00 00 00 01 00 01 00 01 00 00 00 00 01 00 01 01 01 01 00 00 01 00 01 01 01 01 01 00 01 01 00 01 01 +01 01 01 00 01 00 00 01 01 00 00 01 01 01 00 00 00 00 01 00 01 00 01 01 01 00 00 00 00 01 01 01 00 01 01 01 01 01 00 00 01 00 01 00 00 00 00 00 00 01 +00 00 00 00 01 01 00 01 00 00 00 01 00 01 00 01 00 00 01 01 00 00 01 00 01 01 00 01 01 00 01 00 00 01 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 01 +01 01 01 01 01 00 00 01 00 00 01 01 00 00 00 00 01 00 00 00 01 00 01 01 01 01 01 01 01 00 00 01 01 01 00 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 +00 00 01 01 01 00 00 01 01 01 01 01 00 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 00 01 00 00 01 00 01 00 +01 01 00 00 01 00 00 01 00 00 01 01 00 00 01 01 00 01 00 01 00 01 01 00 00 01 01 01 01 00 00 00 01 00 00 00 00 01 00 00 01 01 00 00 01 01 01 01 01 00 +00 01 01 01 00 01 00 01 00 01 01 00 01 00 00 00 01 00 01 01 01 00 00 01 00 00 00 00 01 01 00 00 01 01 01 01 00 00 00 00 01 01 01 01 01 01 01 00 00 00 +01 01 00 00 00 01 00 00 01 01 00 01 01 01 00 01 00 00 01 00 00 00 01 01 01 00 01 00 01 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 01 00 00 01 00 01 +01 00 00 00 00 01 01 01 00 00 00 00 00 00 01 01 00 01 01 00 00 01 01 00 01 00 00 01 00 00 01 01 01 01 00 01 00 01 00 00 01 00 01 01 00 00 00 00 00 00 +00 00 01 01 01 00 00 01 00 00 00 01 01 01 00 01 00 00 00 00 01 01 00 00 01 00 00 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 00 01 00 00 01 00 01 01 +00 00 01 00 00 00 00 00 01 00 01 01 01 00 00 01 00 01 01 01 01 01 01 01 00 01 00 01 00 01 01 00 01 00 01 01 00 01 01 01 00 00 00 01 00 00 00 00 00 01 +00 01 00 01 00 00 00 00 00 00 01 01 01 00 01 00 01 01 01 01 00 01 01 01 00 00 01 00 00 01 01 00 00 01 01 01 00 00 01 00 00 01 01 01 01 00 01 01 01 01 +00 01 00 01 00 01 01 00 01 00 01 01 00 00 00 00 01 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 01 01 00 00 01 00 01 01 00 00 01 00 01 01 01 01 01 +01 00 00 01 01 00 00 01 01 00 01 00 00 01 01 01 00 01 00 00 00 01 00 01 01 00 00 00 01 01 00 01 01 00 00 01 00 00 00 01 00 01 01 00 01 00 01 01 01 00 +01 00 01 00 01 00 00 01 01 00 00 01 01 00 01 01 01 01 01 01 00 01 00 00 01 01 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 01 00 01 00 01 +00 01 00 01 01 01 00 01 00 01 01 00 01 01 00 01 00 01 01 00 00 00 01 01 01 01 00 00 01 01 01 01 00 00 00 01 01 01 00 01 00 00 00 01 01 00 00 00 01 01 +00 00 01 01 01 01 01 01 01 00 00 00 01 00 00 00 01 00 01 00 01 01 00 01 00 01 00 00 01 01 01 XX 01 01 01 00 00 00 00 01 00 00 01 00 01 00 00 00 00 01 +00 01 00 00 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 01 01 00 01 01 01 01 01 00 01 01 01 00 00 01 01 01 01 01 01 +00 01 01 01 00 01 01 01 01 01 00 00 00 00 01 00 00 00 01 00 01 00 01 01 01 00 00 00 00 00 01 00 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 01 01 +01 00 00 00 00 01 01 00 01 01 00 01 01 01 01 00 00 01 00 00 01 01 00 00 01 01 01 01 01 01 01 00 01 01 01 01 00 00 00 01 01 00 00 00 00 00 00 00 01 00 +01 00 01 01 00 01 00 00 00 00 01 01 00 00 00 01 00 00 01 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 01 00 01 00 00 01 00 01 01 00 00 01 00 00 00 01 +00 00 00 00 00 00 01 01 01 00 00 01 00 00 01 01 01 00 01 01 00 01 01 01 00 01 00 00 01 00 01 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 00 00 01 +01 00 01 00 01 01 01 00 01 00 00 00 01 01 00 01 00 00 01 00 01 00 00 01 00 01 01 00 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 01 01 01 00 01 01 01 +01 00 01 00 00 00 01 01 00 01 01 00 00 00 01 01 00 01 00 00 00 00 00 00 01 00 01 01 01 01 00 01 01 00 01 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 +00 00 01 01 00 00 01 00 01 00 01 00 01 00 00 00 00 00 01 01 00 00 01 01 00 00 00 01 00 00 00 01 00 00 00 01 00 01 01 00 01 00 00 01 00 00 01 00 00 00 +01 00 01 01 00 01 01 00 00 01 00 00 00 00 00 00 01 01 01 00 01 01 00 01 00 01 01 01 01 01 00 01 01 01 00 01 00 01 01 00 00 01 00 01 00 01 01 01 00 01 +00 01 00 00 00 00 01 01 01 01 00 01 00 01 00 00 01 00 01 00 00 01 00 01 00 00 00 00 01 00 01 01 01 01 00 01 01 01 00 00 00 00 00 00 01 00 00 00 01 01 +01 01 01 01 00 01 01 00 01 00 00 00 00 01 01 00 00 00 01 00 01 00 00 01 00 00 01 01 00 00 00 01 00 01 00 00 01 01 01 00 00 01 01 00 01 00 00 01 01 01 +00 00 01 00 01 00 00 00 01 01 01 01 00 01 01 01 01 00 00 00 00 00 00 01 00 01 00 00 00 01 00 00 01 01 01 00 01 01 00 00 00 01 00 01 00 01 00 00 01 00 +00 01 01 00 01 01 01 01 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 00 01 00 00 01 01 01 00 01 00 00 00 01 00 01 01 00 01 01 00 00 01 00 01 00 01 +00 01 00 01 01 01 01 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 01 00 00 01 01 00 00 01 01 01 01 00 00 00 00 01 00 01 00 01 01 00 00 01 00 01 +00 00 00 00 01 01 00 01 01 01 01 01 00 00 00 01 01 00 01 01 00 00 00 00 01 01 00 01 00 01 00 00 01 00 00 00 01 00 01 00 01 00 00 01 00 00 01 01 01 00 + +Spaces to left edge 31 clipping 31 +Spaces to right edge 18 clipping 18 +Spaces to upper edge 34 clipping 34 +Spaces to lower edge 15 clipping 15 +Total spaces in clip 2500 +00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 01 00 00 00 01 01 00 01 00 01 01 00 00 00 00 00 01 01 01 01 00 01 01 00 01 01 01 01 01 00 01 00 00 01 +01 01 00 01 00 00 01 01 00 01 01 01 00 00 00 01 00 00 00 01 01 01 00 00 01 01 00 00 01 00 01 00 01 01 00 01 00 01 00 00 00 00 01 00 00 00 01 00 00 01 +01 01 01 01 00 00 00 00 00 00 01 01 00 00 00 00 00 00 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 00 00 00 00 01 01 00 01 00 01 01 00 00 00 00 00 01 +01 01 01 01 00 00 00 00 00 00 01 01 01 00 00 01 00 00 00 01 01 01 01 00 01 00 00 01 00 01 00 01 00 00 01 00 00 01 01 00 01 00 01 00 00 01 00 01 00 00 +00 01 00 00 01 01 00 00 00 00 01 00 00 01 00 01 00 00 00 01 00 00 01 00 00 00 01 00 01 01 01 01 00 01 01 00 00 01 00 00 00 01 00 00 00 01 01 00 01 01 +01 00 01 01 00 00 01 01 00 00 01 01 01 01 00 01 01 00 00 01 00 00 00 01 00 01 00 01 01 01 01 01 01 00 00 01 00 01 01 01 01 00 00 00 01 01 01 01 01 00 +00 00 00 01 01 01 00 01 00 01 00 01 00 00 00 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 00 01 00 01 00 01 00 00 00 00 00 01 00 00 01 00 01 00 00 00 +01 00 01 01 00 00 01 01 00 00 01 01 00 00 00 00 01 00 01 00 00 01 01 00 01 00 00 00 00 01 01 01 01 00 01 01 00 00 00 00 01 01 01 01 01 01 01 01 01 00 +01 00 01 00 00 01 00 01 01 00 00 00 00 01 00 01 00 00 01 00 01 00 01 00 01 01 00 01 00 01 01 01 01 01 01 00 00 01 01 01 01 01 00 01 00 00 00 00 01 00 +00 00 00 01 00 00 00 00 01 00 00 00 01 01 01 00 01 01 01 00 01 01 01 01 00 01 01 01 01 00 01 01 00 01 01 01 01 01 01 00 00 01 01 01 01 00 00 00 00 01 +01 01 00 00 00 01 00 01 00 01 00 01 01 00 00 00 01 00 01 01 00 01 00 01 01 01 00 01 00 00 00 01 01 01 01 01 00 01 00 00 01 00 01 00 01 01 00 00 01 01 +01 00 01 00 01 00 01 01 01 01 01 01 00 00 00 00 01 00 01 00 00 00 00 01 00 01 01 00 00 00 00 01 00 01 01 00 01 01 01 00 00 01 01 01 01 00 01 01 00 00 +01 01 01 01 00 01 01 01 00 01 00 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 01 01 01 00 00 00 01 01 00 01 00 01 01 00 00 01 00 00 01 01 00 00 01 01 +00 01 01 01 01 01 01 00 01 01 00 01 01 01 00 01 01 00 00 00 01 00 01 01 01 00 01 01 00 00 01 00 00 00 01 01 01 01 01 00 00 00 01 01 01 01 01 00 00 01 +00 01 00 01 00 01 00 01 00 00 00 01 01 00 01 00 01 01 01 00 01 01 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 01 01 01 01 00 00 01 00 00 00 01 00 +01 00 01 01 01 00 01 00 00 00 00 00 01 00 01 01 00 00 00 01 01 01 01 01 01 00 01 01 01 00 01 00 01 01 01 00 01 01 00 00 01 01 00 00 01 01 01 01 01 01 +00 00 00 01 00 01 00 01 01 01 00 00 01 01 01 00 01 01 01 00 01 00 01 01 00 00 00 00 01 00 01 01 00 00 01 00 01 01 00 00 00 00 01 01 01 00 01 00 01 01 +00 00 01 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 01 00 01 00 01 00 01 00 00 00 01 01 01 01 00 00 01 00 00 01 00 00 00 00 01 00 01 00 01 01 +01 00 01 00 01 00 00 00 01 00 00 00 01 01 01 00 00 00 00 00 01 00 01 00 01 00 00 00 00 01 00 01 01 01 01 00 00 01 00 01 01 01 01 01 00 01 01 00 01 01 +01 01 01 00 01 00 00 01 01 00 00 01 01 01 00 00 00 00 01 00 01 00 01 01 01 00 00 00 00 01 01 01 00 01 01 01 01 01 00 00 01 00 01 00 00 00 00 00 00 01 +00 00 00 00 01 01 00 01 00 00 00 01 00 01 00 01 00 00 01 01 00 00 01 00 01 01 00 01 01 00 01 00 00 01 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 01 +01 01 01 01 01 00 00 01 00 00 01 01 00 00 00 00 01 00 00 00 01 00 01 01 01 01 01 01 01 00 00 01 01 01 00 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 +00 00 01 01 01 00 00 01 01 01 01 01 00 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 00 01 00 00 01 00 01 00 +01 01 00 00 01 00 00 01 00 00 01 01 00 00 01 01 00 01 00 01 00 01 01 00 00 01 01 01 01 00 00 00 01 00 00 00 00 01 00 00 01 01 00 00 01 01 01 01 01 00 +00 01 01 01 00 01 00 01 00 01 01 00 01 00 00 00 01 00 01 01 01 00 00 01 00 00 00 00 01 01 00 00 01 01 01 01 00 00 00 00 01 01 01 01 01 01 01 00 00 00 +01 01 00 00 00 01 00 00 01 01 00 01 01 01 00 01 00 00 01 00 00 00 01 01 01 00 01 00 01 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 01 00 00 01 00 01 +01 00 00 00 00 01 01 01 00 00 00 00 00 00 01 01 00 01 01 00 00 01 01 00 01 00 00 01 00 00 01 01 01 01 00 01 00 01 00 00 01 00 01 01 00 00 00 00 00 00 +00 00 01 01 01 00 00 01 00 00 00 01 01 01 00 01 00 00 00 00 01 01 00 00 01 00 00 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 00 01 00 00 01 00 01 01 +00 00 01 00 00 00 00 00 01 00 01 01 01 00 00 01 00 01 01 01 01 01 01 01 00 01 00 01 00 01 01 00 01 00 01 01 00 01 01 01 00 00 00 01 00 00 00 00 00 01 +00 01 00 01 00 00 00 00 00 00 01 01 01 00 01 00 01 01 01 01 00 01 01 01 00 00 01 00 00 01 01 00 00 01 01 01 00 00 01 00 00 01 01 01 01 00 01 01 01 01 +00 01 00 01 00 01 01 00 01 00 01 01 00 00 00 00 01 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 01 01 00 00 01 00 01 01 00 00 01 00 01 01 01 01 01 +01 00 00 01 01 00 00 01 01 00 01 00 00 01 01 01 00 01 00 00 00 01 00 01 01 00 00 00 01 01 00 01 01 00 00 01 00 00 00 01 00 01 01 00 01 00 01 01 01 00 +01 00 01 00 01 00 00 01 01 00 00 01 01 00 01 01 01 01 01 01 00 01 00 00 01 01 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 01 00 01 00 01 +00 01 00 01 01 01 00 01 00 01 01 00 01 01 00 01 00 01 01 00 00 00 01 01 01 01 00 00 01 01 01 01 00 00 00 01 01 01 00 01 00 00 00 01 01 00 00 00 01 01 +00 00 01 01 01 01 01 01 01 00 00 00 01 00 00 00 01 00 01 00 01 01 00 01 00 01 00 00 01 01 01 XX 01 01 01 00 00 00 00 01 00 00 01 00 01 00 00 00 00 01 +00 01 00 00 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 01 01 00 01 01 01 01 01 00 01 01 01 00 00 01 01 01 01 01 01 +00 01 01 01 00 01 01 01 01 01 00 00 00 00 01 00 00 00 01 00 01 00 01 01 01 00 00 00 00 00 01 00 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 01 01 +01 00 00 00 00 01 01 00 01 01 00 01 01 01 01 00 00 01 00 00 01 01 00 00 01 01 01 01 01 01 01 00 01 01 01 01 00 00 00 01 01 00 00 00 00 00 00 00 01 00 +01 00 01 01 00 01 00 00 00 00 01 01 00 00 00 01 00 00 01 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 01 00 01 00 00 01 00 01 01 00 00 01 00 00 00 01 +00 00 00 00 00 00 01 01 01 00 00 01 00 00 01 01 01 00 01 01 00 01 01 01 00 01 00 00 01 00 01 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 00 00 01 +01 00 01 00 01 01 01 00 01 00 00 00 01 01 00 01 00 00 01 00 01 00 00 01 00 01 01 00 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 01 01 01 00 01 01 01 +01 00 01 00 00 00 01 01 00 01 01 00 00 00 01 01 00 01 00 00 00 00 00 00 01 00 01 01 01 01 00 01 01 00 01 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 +00 00 01 01 00 00 01 00 01 00 01 00 01 00 00 00 00 00 01 01 00 00 01 01 00 00 00 01 00 00 00 01 00 00 00 01 00 01 01 00 01 00 00 01 00 00 01 00 00 00 +01 00 01 01 00 01 01 00 00 01 00 00 00 00 00 00 01 01 01 00 01 01 00 01 00 01 01 01 01 01 00 01 01 01 00 01 00 01 01 00 00 01 00 01 00 01 01 01 00 01 +00 01 00 00 00 00 01 01 01 01 00 01 00 01 00 00 01 00 01 00 00 01 00 01 00 00 00 00 01 00 01 01 01 01 00 01 01 01 00 00 00 00 00 00 01 00 00 00 01 01 +01 01 01 01 00 01 01 00 01 00 00 00 00 01 01 00 00 00 01 00 01 00 00 01 00 00 01 01 00 00 00 01 00 01 00 00 01 01 01 00 00 01 01 00 01 00 00 01 01 01 +00 00 01 00 01 00 00 00 01 01 01 01 00 01 01 01 01 00 00 00 00 00 00 01 00 01 00 00 00 01 00 00 01 01 01 00 01 01 00 00 00 01 00 01 00 01 00 00 01 00 +00 01 01 00 01 01 01 01 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 00 01 00 00 01 01 01 00 01 00 00 00 01 00 01 01 00 01 01 00 00 01 00 01 00 01 +00 01 00 01 01 01 01 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 01 00 00 01 01 00 00 01 01 01 01 00 00 00 00 01 00 01 00 01 01 00 00 01 00 01 +00 00 00 00 01 01 00 01 01 01 01 01 00 00 00 01 01 00 01 01 00 00 00 00 01 01 00 01 00 01 00 00 01 00 00 00 01 00 01 00 01 00 00 01 00 00 01 01 01 00 +Open spaces 1274 +Target is global pointer pos 646 (from saved file) +Target is 646 +00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 01 00 00 00 01 01 00 01 00 01 01 00 00 00 00 00 01 01 01 01 00 01 01 00 01 01 01 01 01 00 01 00 00 01 +01 01 00 01 00 00 01 01 00 01 01 01 00 00 00 01 00 00 00 01 01 01 00 00 01 01 00 00 01 00 01 00 01 01 00 01 00 01 00 00 00 00 01 00 00 00 01 00 00 01 +01 01 01 01 00 00 00 00 00 00 01 01 00 00 00 00 00 00 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 00 00 00 00 01 01 00 01 00 01 01 00 00 00 00 00 01 +01 01 01 01 00 00 00 00 00 00 01 01 01 00 00 01 00 00 00 01 01 01 01 00 01 00 00 01 00 01 00 01 00 00 01 00 00 01 01 00 01 00 01 00 00 01 00 01 00 00 +00 01 00 00 01 01 00 00 00 00 01 00 00 01 00 01 00 00 00 01 00 00 01 00 00 00 01 00 01 01 01 01 00 01 01 00 00 01 00 00 00 01 00 00 00 01 01 00 01 01 +01 00 01 01 00 00 01 01 00 00 01 01 01 01 00 01 01 00 00 01 00 00 00 01 00 01 00 01 01 01 01 01 01 00 00 01 00 01 01 01 01 00 00 00 01 01 01 01 01 00 +00 00 00 01 01 01 00 01 00 01 00 01 00 00 00 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 00 01 00 01 00 01 00 00 00 00 00 01 00 00 01 00 01 00 00 00 +01 00 01 01 00 00 01 01 00 00 01 01 00 00 00 00 01 00 01 00 00 01 01 00 01 00 00 00 00 01 01 01 01 00 01 01 00 00 00 00 01 01 01 01 01 01 01 01 01 00 +01 00 01 00 00 01 00 01 01 00 00 00 00 01 00 01 00 00 01 00 01 00 01 00 01 01 00 01 00 01 01 01 01 01 01 00 00 01 01 01 01 01 00 01 00 00 00 00 01 00 +00 00 00 01 00 00 00 00 01 00 00 00 01 01 01 00 01 01 01 00 01 01 01 01 00 01 01 01 01 00 01 01 00 01 01 01 01 01 01 00 00 01 01 01 01 00 00 00 00 01 +01 01 00 00 00 01 00 01 00 01 00 01 01 00 00 00 01 00 01 01 00 01 00 01 01 01 00 01 00 00 00 01 01 01 01 01 00 01 00 00 01 00 01 00 01 01 00 00 01 01 +01 00 01 00 01 00 01 01 01 01 01 01 00 00 00 00 01 00 01 00 00 00 00 01 00 01 01 00 00 00 00 01 00 01 01 00 01 01 01 00 00 01 01 01 01 00 01 01 00 00 +01 01 01 01 00 01 01 01 00 01 00 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 01 01 01 00 00 00 01 01 00 01 00 01 01 00 00 01 00 00 01 01 -- 00 01 01 +00 01 01 01 01 01 01 00 01 01 00 01 01 01 00 01 01 00 00 00 01 00 01 01 01 00 01 01 00 00 01 00 00 00 01 01 01 01 01 00 00 00 01 01 01 01 01 00 00 01 +00 01 00 01 00 01 00 01 00 00 00 01 01 00 01 00 01 01 01 00 01 01 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 01 01 01 01 00 00 01 00 00 00 01 00 +01 00 01 01 01 00 01 00 00 00 00 00 01 00 01 01 00 00 00 01 01 01 01 01 01 00 01 01 01 00 01 00 01 01 01 00 01 01 00 00 01 01 00 00 01 01 01 01 01 01 +00 00 00 01 00 01 00 01 01 01 00 00 01 01 01 00 01 01 01 00 01 00 01 01 00 00 00 00 01 00 01 01 00 00 01 00 01 01 00 00 00 00 01 01 01 00 01 00 01 01 +00 00 01 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 01 00 01 00 01 00 01 00 00 00 01 01 01 01 00 00 01 00 00 01 00 00 00 00 01 00 01 00 01 01 +01 00 01 00 01 00 00 00 01 00 00 00 01 01 01 00 00 00 00 00 01 00 01 00 01 00 00 00 00 01 00 01 01 01 01 00 00 01 00 01 01 01 01 01 00 01 01 00 01 01 +01 01 01 00 01 00 00 01 01 00 00 01 01 01 00 00 00 00 01 00 01 00 01 01 01 00 00 00 00 01 01 01 00 01 01 01 01 01 00 00 01 00 01 00 00 00 00 00 00 01 +00 00 00 00 01 01 00 01 00 00 00 01 00 01 00 01 00 00 01 01 00 00 01 00 01 01 00 01 01 00 01 00 00 01 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 01 +01 01 01 01 01 00 00 01 00 00 01 01 00 00 00 00 01 00 00 00 01 00 01 01 01 01 01 01 01 00 00 01 01 01 00 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 +00 00 01 01 01 00 00 01 01 01 01 01 00 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 00 01 00 00 01 00 01 00 +01 01 00 00 01 00 00 01 00 00 01 01 00 00 01 01 00 01 00 01 00 01 01 00 00 01 01 01 01 00 00 00 01 00 00 00 00 01 00 00 01 01 00 00 01 01 01 01 01 00 +00 01 01 01 00 01 00 01 00 01 01 00 01 00 00 00 01 00 01 01 01 00 00 01 00 00 00 00 01 01 00 00 01 01 01 01 00 00 00 00 01 01 01 01 01 01 01 00 00 00 +01 01 00 00 00 01 00 00 01 01 00 01 01 01 00 01 00 00 01 00 00 00 01 01 01 00 01 00 01 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 01 00 00 01 00 01 +01 00 00 00 00 01 01 01 00 00 00 00 00 00 01 01 00 01 01 00 00 01 01 00 01 00 00 01 00 00 01 01 01 01 00 01 00 01 00 00 01 00 01 01 00 00 00 00 00 00 +00 00 01 01 01 00 00 01 00 00 00 01 01 01 00 01 00 00 00 00 01 01 00 00 01 00 00 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 00 01 00 00 01 00 01 01 +00 00 01 00 00 00 00 00 01 00 01 01 01 00 00 01 00 01 01 01 01 01 01 01 00 01 00 01 00 01 01 00 01 00 01 01 00 01 01 01 00 00 00 01 00 00 00 00 00 01 +00 01 00 01 00 00 00 00 00 00 01 01 01 00 01 00 01 01 01 01 00 01 01 01 00 00 01 00 00 01 01 00 00 01 01 01 00 00 01 00 00 01 01 01 01 00 01 01 01 01 +00 01 00 01 00 01 01 00 01 00 01 01 00 00 00 00 01 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 01 01 00 00 01 00 01 01 00 00 01 00 01 01 01 01 01 +01 00 00 01 01 00 00 01 01 00 01 00 00 01 01 01 00 01 00 00 00 01 00 01 01 00 00 00 01 01 00 01 01 00 00 01 00 00 00 01 00 01 01 00 01 00 01 01 01 00 +01 00 01 00 01 00 00 01 01 00 00 01 01 00 01 01 01 01 01 01 00 01 00 00 01 01 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 01 00 01 00 01 +00 01 00 01 01 01 00 01 00 01 01 00 01 01 00 01 00 01 01 00 00 00 01 01 01 01 00 00 01 01 01 01 00 00 00 01 01 01 00 01 00 00 00 01 01 00 00 00 01 01 +00 00 01 01 01 01 01 01 01 00 00 00 01 00 00 00 01 00 01 00 01 01 00 01 00 01 00 00 01 01 01 XX 01 01 01 00 00 00 00 01 00 00 01 00 01 00 00 00 00 01 +00 01 00 00 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 01 01 00 01 01 01 01 01 00 01 01 01 00 00 01 01 01 01 01 01 +00 01 01 01 00 01 01 01 01 01 00 00 00 00 01 00 00 00 01 00 01 00 01 01 01 00 00 00 00 00 01 00 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 01 01 +01 00 00 00 00 01 01 00 01 01 00 01 01 01 01 00 00 01 00 00 01 01 00 00 01 01 01 01 01 01 01 00 01 01 01 01 00 00 00 01 01 00 00 00 00 00 00 00 01 00 +01 00 01 01 00 01 00 00 00 00 01 01 00 00 00 01 00 00 01 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 01 00 01 00 00 01 00 01 01 00 00 01 00 00 00 01 +00 00 00 00 00 00 01 01 01 00 00 01 00 00 01 01 01 00 01 01 00 01 01 01 00 01 00 00 01 00 01 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 00 00 01 +01 00 01 00 01 01 01 00 01 00 00 00 01 01 00 01 00 00 01 00 01 00 00 01 00 01 01 00 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 01 01 01 00 01 01 01 +01 00 01 00 00 00 01 01 00 01 01 00 00 00 01 01 00 01 00 00 00 00 00 00 01 00 01 01 01 01 00 01 01 00 01 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 +00 00 01 01 00 00 01 00 01 00 01 00 01 00 00 00 00 00 01 01 00 00 01 01 00 00 00 01 00 00 00 01 00 00 00 01 00 01 01 00 01 00 00 01 00 00 01 00 00 00 +01 00 01 01 00 01 01 00 00 01 00 00 00 00 00 00 01 01 01 00 01 01 00 01 00 01 01 01 01 01 00 01 01 01 00 01 00 01 01 00 00 01 00 01 00 01 01 01 00 01 +00 01 00 00 00 00 01 01 01 01 00 01 00 01 00 00 01 00 01 00 00 01 00 01 00 00 00 00 01 00 01 01 01 01 00 01 01 01 00 00 00 00 00 00 01 00 00 00 01 01 +01 01 01 01 00 01 01 00 01 00 00 00 00 01 01 00 00 00 01 00 01 00 00 01 00 00 01 01 00 00 00 01 00 01 00 00 01 01 01 00 00 01 01 00 01 00 00 01 01 01 +00 00 01 00 01 00 00 00 01 01 01 01 00 01 01 01 01 00 00 00 00 00 00 01 00 01 00 00 00 01 00 00 01 01 01 00 01 01 00 00 00 01 00 01 00 01 00 00 01 00 +00 01 01 00 01 01 01 01 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 00 01 00 00 01 01 01 00 01 00 00 00 01 00 01 01 00 01 01 00 00 01 00 01 00 01 +00 01 00 01 01 01 01 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 01 00 00 01 01 00 00 01 01 01 01 00 00 00 00 01 00 01 00 01 01 00 00 01 00 01 +00 00 00 00 01 01 00 01 01 01 01 01 00 00 00 01 01 00 01 01 00 00 00 00 01 01 00 01 00 01 00 00 01 00 00 00 01 00 01 00 01 00 00 01 00 00 01 01 01 00 + + +dumping idx 1731 + +dumping idx 1682 + +dumping idx 1633 + +dumping idx 1584 + +dumping idx 1535 + +dumping idx 1486 + +dumping idx 1436 + +dumping idx 1387 + +dumping idx 1338 + +dumping idx 1288 + +dumping idx 1239 + +dumping idx 1189 + +dumping idx 1140 + +dumping idx 1091 + +dumping idx 1042 + +dumping idx 993 + +dumping idx 944 + +dumping idx 895 + +dumping idx 845 + +dumping idx 994 + +dumping idx 1043 + +dumping idx 893 + +dumping idx 995 + +dumping idx 996 + +dumping idx 1044 + +dumping idx 1045 + +dumping idx 1046 + +dumping idx 947 + +dumping idx 998 + +dumping idx 897 + +dumping idx 847 + +dumping idx 1141 + +dumping idx 997 + +dumping idx 1048 + +dumping idx 1099 + +dumping idx 1149 + +dumping idx 1199 + +dumping idx 1248 + +dumping idx 1249 + +dumping idx 1298 + +dumping idx 1247 + +dumping idx 1349 + +dumping idx 1090 + +dumping idx 1348 + +dumping idx 1142 + +dumping idx 1397 + +dumping idx 1448 + +dumping idx 1096 + +dumping idx 1447 + +dumping idx 1040 + +dumping idx 1097 + +dumping idx 1296 + +dumping idx 1347 + +dumping idx 1295 + +dumping idx 1346 + +dumping idx 1345 + +dumping idx 1446 + +dumping idx 1344 + +dumping idx 1395 + +dumping idx 1394 + +dumping idx 1445 + +dumping idx 1147 + +dumping idx 1495 + +dumping idx 1444 + +dumping idx 991 + +dumping idx 1047 + +dumping idx 1093 + +dumping idx 1094 + +dumping idx 1144 + +dumping idx 892 + +dumping idx 1339 + +dumping idx 1238 + +dumping idx 989 + +dumping idx 1145 + +dumping idx 1089 + +dumping idx 1290 + +dumping idx 1291 + +dumping idx 1292 + +dumping idx 1188 + +dumping idx 1192 + +dumping idx 1193 + +dumping idx 1039 + +dumping idx 1544 + +dumping idx 1341 + +dumping idx 841 + +dumping idx 792 + +dumping idx 743 + +dumping idx 742 + +dumping idx 793 + +dumping idx 691 + +dumping idx 642 + +dumping idx 643 + +dumping idx 840 + +dumping idx 640 + +dumping idx 690 + +dumping idx 890 + +dumping idx 789 + +dumping idx 839 + +dumping idx 590 + +dumping idx 639 + +dumping idx 689 + +dumping idx 788 + +dumping idx 589 + +dumping idx 541 + +dumping idx 838 + +dumping idx 737 + +dumping idx 888 + +dumping idx 539 + +dumping idx 736 + +dumping idx 538 + +dumping idx 490 + +dumping idx 887 + +dumping idx 489 + +dumping idx 735 + +dumping idx 785 + +dumping idx 936 + +dumping idx 734 + +dumping idx 835 + +dumping idx 885 + +dumping idx 683 + +dumping idx 634 + +dumping idx 935 + +dumping idx 585 + +dumping idx 636 + +dumping idx 884 + +dumping idx 682 + +dumping idx 536 + +dumping idx 833 + +dumping idx 631 + +dumping idx 681 + +dumping idx 582 + +dumping idx 832 + +dumping idx 630 + +dumping idx 580 + +dumping idx 781 + +dumping idx 629 + +dumping idx 679 + +dumping idx 579 + +dumping idx 530 + +dumping idx 529 + +dumping idx 578 + +dumping idx 678 + +dumping idx 729 + +dumping idx 1487 + +dumping idx 1390 + +dumping idx 938 + +dumping idx 1237 + +dumping idx 988 + +dumping idx 891 + +dumping idx 1038 + +dumping idx 1037 + +dumping idx 1087 + +dumping idx 1036 + +dumping idx 1086 + +dumping idx 1136 + +dumping idx 1085 + +dumping idx 1135 + +dumping idx 1034 + +dumping idx 1084 + +dumping idx 1185 + +dumping idx 1184 + +dumping idx 1186 + +dumping idx 1133 + +dumping idx 1287 + +dumping idx 1536 + +dumping idx 1595 + +dumping idx 528 + +dumping idx 1336 + +dumping idx 479 + +dumping idx 1236 + +dumping idx 728 + +dumping idx 1392 + +dumping idx 1538 + +dumping idx 1489 + +dumping idx 1490 + +dumping idx 779 + +dumping idx 1385 + +dumping idx 577 + +dumping idx 1441 + +dumping idx 1183 + +dumping idx 1634 + +dumping idx 1286 + +dumping idx 1440 + +dumping idx 1583 + +dumping idx 1132 + +dumping idx 1586 + +dumping idx 1442 + +dumping idx 1587 + +dumping idx 1285 + +dumping idx 1541 + +dumping idx 1646 + +dumping idx 1542 + +dumping idx 1683 + +dumping idx 1632 + +dumping idx 727 + +dumping idx 1588 + +dumping idx 1593 + +dumping idx 1684 + +dumping idx 1334 + +dumping idx 1532 + +dumping idx 1482 + +dumping idx 1433 + +dumping idx 829 + +dumping idx 1637 + +dumping idx 1384 + +dumping idx 1284 + +dumping idx 1638 + +dumping idx 1631 + +dumping idx 1735 + +dumping idx 1736 + +dumping idx 1737 + +dumping idx 1738 + +dumping idx 1131 + +dumping idx 1636 + +dumping idx 428 + +dumping idx 1696 + +dumping idx 1644 + +dumping idx 1688 + +dumping idx 1782 + +dumping idx 1481 + +dumping idx 1431 + +dumping idx 1381 + +dumping idx 726 + +dumping idx 526 + +dumping idx 1531 + +dumping idx 1580 + +dumping idx 1788 + +dumping idx 1181 + +dumping idx 1080 + +dumping idx 1031 + +dumping idx 982 + +dumping idx 1032 + +dumping idx 879 + +dumping idx 1590 + +dumping idx 1695 + +dumping idx 1697 + +dumping idx 1630 + +dumping idx 1530 + +dumping idx 1833 + +dumping idx 1642 + +dumping idx 675 + +dumping idx 1746 + +dumping idx 378 + +dumping idx 625 + +dumping idx 1529 + +dumping idx 1839 + +dumping idx 725 + +dumping idx 878 + +dumping idx 930 + +dumping idx 1029 + +dumping idx 1641 + +dumping idx 1648 + +dumping idx 1838 + +dumping idx 1180 + +dumping idx 1231 + +dumping idx 1079 + +dumping idx 1747 + +dumping idx 1640 + +dumping idx 1745 + +dumping idx 377 + +dumping idx 624 + +dumping idx 329 + +dumping idx 330 + +dumping idx 1831 + +dumping idx 1629 + +dumping idx 1478 + +dumping idx 1428 + +dumping idx 1379 + +dumping idx 1329 + +dumping idx 1378 + +dumping idx 775 + +dumping idx 1328 + +dumping idx 1692 + +dumping idx 978 + +dumping idx 827 + +dumping idx 1599 + +dumping idx 1528 + +dumping idx 1837 + +dumping idx 1282 + +dumping idx 1129 + +dumping idx 877 + +dumping idx 928 + +dumping idx 1230 + +dumping idx 1748 + +dumping idx 426 + +dumping idx 1691 + +dumping idx 1888 + +dumping idx 1280 + +dumping idx 1277 + +dumping idx 1281 + +dumping idx 1179 + +dumping idx 1227 + +dumping idx 826 + +dumping idx 1690 + +dumping idx 1743 + +dumping idx 327 + +dumping idx 574 + +dumping idx 376 + +dumping idx 1881 + +dumping idx 927 + +dumping idx 1628 + +dumping idx 1477 + +dumping idx 977 + +dumping idx 825 + +dumping idx 1887 + +dumping idx 1128 + +dumping idx 1226 + +dumping idx 1741 + +dumping idx 1577 + +dumping idx 1938 + +dumping idx 1932 + +dumping idx 1933 + +dumping idx 1426 + +dumping idx 1376 + +dumping idx 1740 + +dumping idx 824 + +dumping idx 375 + +dumping idx 926 + +dumping idx 1793 + +dumping idx 1931 + +dumping idx 1627 + +dumping idx 1886 + +dumping idx 875 + +dumping idx 976 + +dumping idx 1792 + +dumping idx 1937 + +dumping idx 1225 + +dumping idx 1326 + +dumping idx 1127 + +dumping idx 1375 + +dumping idx 1325 + +dumping idx 276 + +dumping idx 325 + +dumping idx 1275 + +dumping idx 1844 + +dumping idx 1988 + +dumping idx 1677 + +dumping idx 1930 + +dumping idx 1576 + +dumping idx 1982 + +dumping idx 925 + +dumping idx 1026 + +dumping idx 1843 + +dumping idx 1626 + +dumping idx 1224 + +dumping idx 975 + +dumping idx 1174 + +dumping idx 1125 + +dumping idx 1124 + +dumping idx 227 + +dumping idx 1842 + +dumping idx 1895 + +dumping idx 1846 + +dumping idx 1126 + +dumping idx 1896 + +dumping idx 1987 + +dumping idx 1475 + +dumping idx 873 + +dumping idx 1894 + +dumping idx 2032 + +dumping idx 1575 + +dumping idx 1676 + +dumping idx 1727 + +dumping idx 2038 + +dumping idx 1935 + +dumping idx 1893 + +dumping idx 1173 + +dumping idx 1841 + +dumping idx 1847 + +dumping idx 178 + +dumping idx 1946 + +dumping idx 1897 + +dumping idx 1948 + +dumping idx 1899 + +dumping idx 1998 + +dumping idx 1986 + +dumping idx 1424 + +dumping idx 225 + +dumping idx 1892 + +dumping idx 1947 + +dumping idx 274 + +dumping idx 2089 + +dumping idx 2083 + +dumping idx 1726 + +dumping idx 1996 + +dumping idx 1997 + +dumping idx 2046 + +dumping idx 2095 + +dumping idx 2097 + +dumping idx 2094 + +dumping idx 2145 + +dumping idx 2098 + +dumping idx 2147 + +dumping idx 2148 + +dumping idx 2144 + +dumping idx 2198 + +dumping idx 2194 + +dumping idx 2149 + +dumping idx 2247 + +dumping idx 2245 + +dumping idx 2246 + +dumping idx 2296 + +dumping idx 2243 + +dumping idx 2295 + +dumping idx 2346 + +dumping idx 2192 + +dumping idx 2242 + +dumping idx 2347 + +dumping idx 2293 + +dumping idx 2396 + +dumping idx 2344 + +dumping idx 2446 + +dumping idx 2394 + +dumping idx 2342 + +dumping idx 2398 + +dumping idx 2445 + +dumping idx 2393 + +dumping idx 1778 + +dumping idx 1979 + +dumping idx 1524 + +dumping idx 1474 + +dumping idx 923 + +dumping idx 1995 + +dumping idx 2142 + +dumping idx 1944 + +dumping idx 1993 + +dumping idx 2141 + +dumping idx 1943 + +dumping idx 1992 + +dumping idx 1991 + +dumping idx 2041 + +dumping idx 1940 + +dumping idx 1990 + +dumping idx 2091 + +dumping idx 2241 + +dumping idx 2190 + +dumping idx 2290 + +dumping idx 1777 + +dumping idx 2349 + +dumping idx 1373 + +dumping idx 1891 + +dumping idx 2240 + +dumping idx 2189 + +dumping idx 1323 + +dumping idx 323 + +dumping idx 176 + +dumping idx 373 + +dumping idx 423 + +dumping idx 474 + +dumping idx 1829 + +dumping idx 2036 + +dumping idx 2030 + +dumping idx 2134 + +dumping idx 2448 + +dumping idx 224 + +dumping idx 2139 + +dumping idx 175 + +dumping idx 2239 + +dumping idx 1828 + +dumping idx 2087 + +dumping idx 2029 + +dumping idx 2495 + +dumping idx 2133 + +dumping idx 1222 + +dumping idx 2289 + +dumping idx 2340 + +dumping idx 1827 + +dumping idx 127 + +dumping idx 76 + +dumping idx 27 + +dumping idx 126 + +dumping idx 28 + +dumping idx 77 + +dumping idx 79 + +dumping idx 29 + +dumping idx 30 + +dumping idx 81 + +dumping idx 132 + +dumping idx 183 + +dumping idx 133 + +dumping idx 182 + +dumping idx 134 + +dumping idx 185 + +dumping idx 236 + +dumping idx 286 + +dumping idx 337 + +dumping idx 388 + +dumping idx 389 + +dumping idx 338 + +dumping idx 387 + +dumping idx 336 + +dumping idx 339 + +dumping idx 340 + +dumping idx 386 + +dumping idx 186 + +dumping idx 436 + +dumping idx 235 + +dumping idx 291 + +dumping idx 342 + +dumping idx 343 + +dumping idx 292 + +dumping idx 232 + +dumping idx 283 + +dumping idx 334 + +dumping idx 135 + +dumping idx 435 + +dumping idx 293 + +dumping idx 136 + +dumping idx 284 + +dumping idx 383 + +dumping idx 332 + +dumping idx 243 + +dumping idx 242 + +dumping idx 244 + +dumping idx 31 + +dumping idx 86 + +dumping idx 84 + +dumping idx 193 + +dumping idx 194 + +dumping idx 240 + +dumping idx 36 + +dumping idx 144 + +dumping idx 145 + +dumping idx 196 + +dumping idx 247 + +dumping idx 146 + +dumping idx 147 + +dumping idx 198 + +dumping idx 97 + +dumping idx 148 + +dumping idx 98 + +dumping idx 199 + +dumping idx 47 + +dumping idx 48 + +dumping idx 191 + +dumping idx 239 + +dumping idx 95 + +dumping idx 45 + +dumping idx 94 + +dumping idx 141 + +dumping idx 189 + +dumping idx 238 + +dumping idx 93 + +dumping idx 91 + +dumping idx 139 + +dumping idx 90 + +dumping idx 89 + +dumping idx 88 + +dumping idx 39 + +dumping idx 2035 + +dumping idx 1372 + +dumping idx 2238 + +dumping idx 322 + +dumping idx 223 + +dumping idx 2132 + +dumping idx 2442 + +dumping idx 1775 + +dumping idx 2494 + +dumping idx 2184 + +dumping idx 2086 + +dumping idx 2080 + +dumping idx 2339 + +dumping idx 1826 + +dumping idx 1221 + +dumping idx 2390 + +dumping idx 272 + +dumping idx 221 + +dumping idx 2499 + +dumping idx 321 + +dumping idx 370 + +dumping idx 421 + +dumping idx 419 + +dumping idx 469 + +dumping idx 520 + +dumping idx 571 + +dumping idx 572 + +dumping idx 570 + +dumping idx 522 + +dumping idx 620 + +dumping idx 270 + +dumping idx 369 + +dumping idx 569 + +dumping idx 619 + +dumping idx 671 + +dumping idx 220 + +dumping idx 319 + +dumping idx 722 + +dumping idx 669 + +dumping idx 668 + +dumping idx 719 + +dumping idx 268 + +dumping idx 617 + +dumping idx 667 + +dumping idx 317 + +dumping idx 271 + +dumping idx 367 + +dumping idx 417 + +dumping idx 267 + +dumping idx 218 + +dumping idx 567 + +dumping idx 616 + +dumping idx 768 + +dumping idx 416 + +dumping idx 217 + +dumping idx 168 + +dumping idx 465 + +dumping idx 517 + +dumping idx 615 + +dumping idx 819 + +dumping idx 515 + +dumping idx 767 + +dumping idx 216 + +dumping idx 167 + +dumping idx 565 + +dumping idx 119 + +dumping idx 564 + +dumping idx 514 + +dumping idx 365 + +dumping idx 166 + +dumping idx 766 + +dumping idx 613 + +dumping idx 117 + +dumping idx 563 + +dumping idx 664 + +dumping idx 868 + +dumping idx 513 + +dumping idx 414 + +dumping idx 315 + +dumping idx 364 + +dumping idx 715 + +dumping idx 612 + +dumping idx 68 + +dumping idx 116 + +dumping idx 919 + +dumping idx 562 + +dumping idx 67 + +dumping idx 918 + +dumping idx 314 + +dumping idx 19 + +dumping idx 815 + +dumping idx 115 + +dumping idx 363 + +dumping idx 611 + +dumping idx 18 + +dumping idx 66 + +dumping idx 969 + +dumping idx 713 + +dumping idx 917 + +dumping idx 17 + +dumping idx 164 + +dumping idx 412 + +dumping idx 313 + +dumping idx 214 + +dumping idx 264 + +dumping idx 114 + +dumping idx 362 + +dumping idx 610 + +dumping idx 1020 + +dumping idx 971 + +dumping idx 921 + +dumping idx 871 + +dumping idx 821 + +dumping idx 1021 + +dumping idx 916 + +dumping idx 763 + +dumping idx 461 + +dumping idx 967 + +dumping idx 163 + +dumping idx 312 + +dumping idx 64 + +dumping idx 411 + +dumping idx 1071 + +dumping idx 660 + +dumping idx 113 + +dumping idx 966 + +dumping idx 510 + +dumping idx 1017 + +dumping idx 212 + +dumping idx 915 + +dumping idx 460 + +dumping idx 14 + +dumping idx 63 + +dumping idx 410 + +dumping idx 710 + +dumping idx 1069 + +dumping idx 1724 + +dumping idx 1016 + +dumping idx 1068 + +dumping idx 965 + +dumping idx 173 + +dumping idx 124 + +dumping idx 2492 + +dumping idx 1825 + +dumping idx 2130 + +dumping idx 2136 + +dumping idx 2234 + +dumping idx 1774 + +dumping idx 112 + +dumping idx 1067 + +dumping idx 459 + +dumping idx 13 + +dumping idx 211 + +dumping idx 761 + +dumping idx 1170 + +dumping idx 1271 + +dumping idx 709 + +dumping idx 1120 + +dumping idx 2338 + +dumping idx 409 + +dumping idx 62 + +dumping idx 760 + +dumping idx 2440 + +dumping idx 2491 + +dumping idx 2285 + +dumping idx 2129 + +dumping idx 964 + +dumping idx 508 + +dumping idx 123 + +dumping idx 72 + +dumping idx 121 + +dumping idx 22 + +dumping idx 2284 + +dumping idx 2180 + +dumping idx 122 + +dumping idx 2186 + +dumping idx 73 + +dumping idx 24 + +dumping idx 359 + +dumping idx 1117 + +dumping idx 12 + +dumping idx 1270 + +dumping idx 759 + +dumping idx 708 + +dumping idx 811 + +dumping idx 810 + +dumping idx 1065 + +dumping idx 1014 + +dumping idx 2335 + +dumping idx 2128 + +dumping idx 310 + +dumping idx 1116 + +dumping idx 1168 + +dumping idx 1320 + +dumping idx 758 + +dumping idx 657 + +dumping idx 608 + +dumping idx 862 + +dumping idx 863 + +dumping idx 2387 + +dumping idx 358 + +dumping idx 1269 + +dumping idx 2489 + +dumping idx 457 + +dumping idx 1064 + +dumping idx 860 + +dumping idx 1115 + +dumping idx 2438 + +dumping idx 2385 + +dumping idx 2229 + +dumping idx 1166 + +dumping idx 308 + +dumping idx 1319 + +dumping idx 757 + +dumping idx 2437 + +dumping idx 506 + +dumping idx 1063 + +dumping idx 1114 + +dumping idx 911 + +dumping idx 859 + +dumping idx 2384 + +dumping idx 2436 + +dumping idx 2280 + +dumping idx 259 + +dumping idx 1217 + +dumping idx 456 + +dumping idx 910 + +dumping idx 706 + +dumping idx 1369 + +dumping idx 2435 + +dumping idx 2279 + +dumping idx 258 + +dumping idx 555 + +dumping idx 1012 + +dumping idx 2331 + +dumping idx 2282 + +dumping idx 2487 + +dumping idx 1113 + +dumping idx 858 + +dumping idx 406 + +dumping idx 1062 + +dumping idx 909 + +dumping idx 2383 + +dumping idx 2278 + +dumping idx 2330 + +dumping idx 1215 + +dumping idx 209 + +dumping idx 960 + +dumping idx 455 + +dumping idx 1267 + +dumping idx 806 + +dumping idx 1368 + +dumping idx 604 + +dumping idx 2485 + +dumping idx 208 + +dumping idx 1112 + +dumping idx 1163 + +dumping idx 2381 + +dumping idx 2227 + +dumping idx 959 + +dumping idx 1266 + +dumping idx 504 + +dumping idx 857 + +dumping idx 755 + +dumping idx 2328 + +dumping idx 2484 + +dumping idx 454 + +dumping idx 207 + +dumping idx 159 + +dumping idx 1214 + +dumping idx 1010 + +dumping idx 1367 + +dumping idx 158 + +dumping idx 1162 + +dumping idx 907 + +dumping idx 553 + +dumping idx 355 + +dumping idx 1213 + +dumping idx 704 + +dumping idx 2226 + +dumping idx 2327 + +dumping idx 503 + +dumping idx 1264 + +dumping idx 1316 + +dumping idx 404 + +dumping idx 1009 + +dumping idx 855 + +dumping idx 2483 + +dumping idx 157 + +dumping idx 206 + +dumping idx 109 + +dumping idx 306 + +dumping idx 1366 + +dumping idx 108 + +dumping idx 2430 + +dumping idx 906 + +dumping idx 354 + +dumping idx 1008 + +dumping idx 804 + +dumping idx 2225 + +dumping idx 2377 + +dumping idx 2326 + +dumping idx 255 + +dumping idx 502 + +dumping idx 551 + +dumping idx 451 + +dumping idx 401 + +dumping idx 450 + +dumping idx 351 + +dumping idx 302 + +dumping idx 301 + +dumping idx 300 + +dumping idx 251 + +dumping idx 202 + +dumping idx 203 + +dumping idx 154 + +dumping idx 200 + +dumping idx 105 + +dumping idx 104 + +dumping idx 55 + +dumping idx 54 + +dumping idx 156 + +dumping idx 106 + +dumping idx 6 + +dumping idx 5 + +dumping idx 107 + +dumping idx 4 + +dumping idx 254 + +dumping idx 3 + +dumping idx 155 + +dumping idx 52 + +dumping idx 452 + +dumping idx 1059 + +dumping idx 403 + +dumping idx 1416 + +dumping idx 1465 + +dumping idx 1414 + +dumping idx 1364 + +dumping idx 1515 + +dumping idx 1514 + +dumping idx 1413 + +dumping idx 1566 + +dumping idx 1517 + +dumping idx 1518 + +dumping idx 1519 + +dumping idx 1470 + +dumping idx 1520 + +dumping idx 1521 + +dumping idx 1313 + +dumping idx 1568 + +dumping idx 1569 + +dumping idx 1572 + +dumping idx 1570 + +dumping idx 1312 + +dumping idx 1463 + +dumping idx 1513 + +dumping idx 1623 + +dumping idx 1620 + +dumping idx 1622 + +dumping idx 1311 + +dumping idx 1671 + +dumping idx 1512 + +dumping idx 1670 + +dumping idx 1260 + +dumping idx 1722 + +dumping idx 1562 + +dumping idx 1310 + +dumping idx 1669 + +dumping idx 1360 + +dumping idx 1613 + +dumping idx 1561 + +dumping idx 1719 + +dumping idx 1309 + +dumping idx 1664 + +dumping idx 1771 + +dumping idx 1359 + +dumping idx 1308 + +dumping idx 1769 + +dumping idx 1715 + +dumping idx 1666 + +dumping idx 1409 + +dumping idx 1714 + +dumping idx 1821 + +dumping idx 1717 + +dumping idx 1610 + +dumping idx 1358 + +dumping idx 1257 + +dumping idx 1208 + +dumping idx 1159 + +dumping idx 1158 + +dumping idx 1766 + +dumping idx 1819 + +dumping idx 1713 + +dumping idx 1872 + +dumping idx 1873 + +dumping idx 1661 + +dumping idx 1764 + +dumping idx 1767 + +dumping idx 1559 + +dumping idx 1459 + +dumping idx 1509 + +dumping idx 1206 + +dumping idx 1156 + +dumping idx 1817 + +dumping idx 1106 + +dumping idx 1256 + +dumping idx 1056 + +dumping idx 1609 + +dumping idx 1006 + +dumping idx 1816 + +dumping idx 1923 + +dumping idx 1924 + +dumping idx 1869 + +dumping idx 956 + +dumping idx 1211 + +dumping idx 58 + +dumping idx 9 + +dumping idx 10 + +dumping idx 8 + +dumping idx 1925 + +dumping idx 1926 + +dumping idx 1927 + +dumping idx 1155 + +dumping idx 1105 + +dumping idx 1763 + +dumping idx 905 + +dumping idx 1055 + +dumping idx 1458 + +dumping idx 955 + +dumping idx 1815 + +dumping idx 1868 + +dumping idx 1922 + +dumping idx 1407 + +dumping idx 1711 + +dumping idx 1977 + +dumping idx 1976 + +dumping idx 1974 + +dumping idx 1920 + +dumping idx 1866 + +dumping idx 1921 + +dumping idx 1919 + +dumping idx 1457 + +dumping idx 1865 + +dumping idx 1710 + +dumping idx 1356 + +dumping idx 1813 + +dumping idx 1406 + +dumping idx 1658 + +dumping idx 2027 + +dumping idx 1917 + +dumping idx 2024 + +dumping idx 1970 + +dumping idx 1916 + +dumping idx 1507 + +dumping idx 1204 + +dumping idx 1812 + +dumping idx 1355 + +dumping idx 1760 + +dumping idx 1456 + +dumping idx 1709 + +dumping idx 2021 + +dumping idx 2075 + +dumping idx 2022 + +dumping idx 1153 + +dumping idx 1967 + +dumping idx 1304 + +dumping idx 1811 + +dumping idx 1254 + +dumping idx 1914 + +dumping idx 1405 + +dumping idx 2481 + +dumping idx 2126 + +dumping idx 1 + +dumping idx 2072 + +dumping idx 1455 + +dumping idx 1810 + +dumping idx 2174 + +dumping idx 2480 + +dumping idx 2429 + +dumping idx 2275 + +dumping idx 2125 + +dumping idx 2073 + +dumping idx 2376 + +dumping idx 2124 + +dumping idx 1058 + +dumping idx 2019 + +dumping idx 2071 + +dumping idx 1152 + +dumping idx 2017 + +dumping idx 2224 + +dumping idx 1404 + +dumping idx 1253 + +dumping idx 1556 + +dumping idx 1913 + +dumping idx 1303 + +dumping idx 1758 + +dumping idx 0 + +dumping idx 2070 + +dumping idx 1860 + +dumping idx 1454 + +dumping idx 2274 + +dumping idx 2426 + +dumping idx 2068 + +dumping idx 1101 + +dumping idx 2016 + +dumping idx 2121 + +dumping idx 2069 + +dumping idx 1403 + +dumping idx 1963 + +dumping idx 1555 + +dumping idx 1252 + +dumping idx 1606 + +dumping idx 1504 + +dumping idx 1302 + +dumping idx 1912 + +dumping idx 2324 + +dumping idx 2425 + +dumping idx 2120 + +dumping idx 2478 + +dumping idx 2172 + +dumping idx 2066 + +dumping idx 1605 + +dumping idx 2014 + +dumping idx 1100 + +dumping idx 2476 + +dumping idx 1962 + +dumping idx 1656 + +dumping idx 2374 + +dumping idx 1301 + +dumping idx 1909 + +dumping idx 2117 + +dumping idx 2222 + +dumping idx 1452 + +dumping idx 2116 + +dumping idx 1351 + +dumping idx 1960 + +dumping idx 2169 + +dumping idx 1908 + +dumping idx 1401 + +dumping idx 1959 + +dumping idx 2115 + +dumping idx 2063 + +dumping idx 2272 + +dumping idx 1502 + +dumping idx 2011 + +dumping idx 2220 + +dumping idx 1857 + +dumping idx 2010 + +dumping idx 1350 + +dumping idx 2114 + +dumping idx 2219 + +dumping idx 2271 + +dumping idx 1400 + +dumping idx 1907 + +dumping idx 2009 + +dumping idx 2062 + +dumping idx 2113 + +dumping idx 2165 + +dumping idx 2322 + +dumping idx 1552 + +dumping idx 2061 + +dumping idx 1450 + +dumping idx 2269 + +dumping idx 2164 + +dumping idx 2321 + +dumping idx 1603 + +dumping idx 1551 + +dumping idx 1906 + +dumping idx 2215 + +dumping idx 2163 + +dumping idx 2111 + +dumping idx 2320 + +dumping idx 2058 + +dumping idx 1500 + +dumping idx 2214 + +dumping idx 2162 + +dumping idx 2266 + +dumping idx 2217 + +dumping idx 2319 + +dumping idx 2267 + +dumping idx 1601 + +dumping idx 2265 + +dumping idx 2109 + +dumping idx 2161 + +dumping idx 2007 + +dumping idx 2318 + +dumping idx 2317 + +dumping idx 1955 + +dumping idx 1652 + +dumping idx 2212 + +dumping idx 2160 + +dumping idx 1904 + +dumping idx 2107 + +dumping idx 1854 + +dumping idx 1804 + +dumping idx 1755 + +dumping idx 1756 + +dumping idx 1954 + +dumping idx 1650 + +dumping idx 2262 + +dumping idx 2210 + +dumping idx 1853 + +dumping idx 1753 + +dumping idx 2158 + +dumping idx 1701 + +dumping idx 2157 + +dumping idx 2261 + +dumping idx 1700 + +dumping idx 1953 + +dumping idx 2312 + +dumping idx 2260 + +dumping idx 1752 + +dumping idx 1852 + +dumping idx 2003 + +dumping idx 1952 + +dumping idx 1750 + +dumping idx 2259 + +dumping idx 2362 + +dumping idx 2054 + +dumping idx 1851 + +dumping idx 2055 + +dumping idx 1901 + +dumping idx 2053 + +dumping idx 2413 + +dumping idx 2414 + +dumping idx 2464 + +dumping idx 2463 + +dumping idx 2462 + +dumping idx 2361 + +dumping idx 2412 + +dumping idx 2411 + +dumping idx 1951 + +dumping idx 1800 + +dumping idx 2105 + +dumping idx 2360 + +dumping idx 2359 + +dumping idx 2409 + +dumping idx 2358 + +dumping idx 2307 + +dumping idx 2257 + +dumping idx 2306 + +dumping idx 2305 + +dumping idx 2254 + +dumping idx 2205 + +dumping idx 2204 + +dumping idx 2203 + +dumping idx 2154 + +dumping idx 2303 + +dumping idx 2104 + +dumping idx 2202 + +dumping idx 2151 + +dumping idx 2101 + +dumping idx 2051 + +dumping idx 2353 + +dumping idx 2001 + +dumping idx 2100 + +dumping idx 1950 + +dumping idx 2200 + +dumping idx 2402 + +dumping idx 2453 + +dumping idx 2452 + +dumping idx 2451 + +dumping idx 2400 + +dumping idx 2350 + +dumping idx 2301 + +dumping idx 2300 + +dumping idx 2450 +number of runs: 1 +total ticks: 18122134 +average ticks: 18122134.000000 +attempted steps: 1216 +No path possible! diff --git a/tests/manhattan.c b/tests/manhattan.c @@ -0,0 +1,30 @@ +// manhattanmagnitude + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include "../lash_game_standard.h" + +int main(int argc, char *argv[]) { + + clock_t test_clock_total = 0.f; + + if (argc<5) { + printf("Usage: %s targetx targety sourcex sourcey\n", argv[0]); + return 1; + } + + lash_game_coords_t targetcoords, sourcecoords; + targetcoords.x = atoi(argv[1]); + targetcoords.y = atoi(argv[2]); + sourcecoords.x = atoi(argv[3]); + sourcecoords.y = atoi(argv[4]); + + clock_t begin = clock(); + int distance = lash_getManhattanMagnitudeFromCartesian(targetcoords, sourcecoords); + test_clock_total += clock() - begin; + + printf("Distance from x%d,y%d to x%d,%d: %d\n", sourcecoords.x, sourcecoords.y, targetcoords.x, targetcoords.y, distance); + printf("Total insert time: %lu ticks @ %li pr sec = %.7f secs\n\n", (long)test_clock_total, CLOCKS_PER_SEC, ((double)test_clock_total / CLOCKS_PER_SEC)); + return 0; +} diff --git a/tests/map.c b/tests/map.c @@ -0,0 +1,28 @@ +// map tests + +#include <stdio.h> +#include "liblashgame/lash_game_standard.h" +#include "liblashgame/lash_game_map.h" + +int main() { + lash_map_simple_t map; + lash_game_coords_t tmpcoords; + lash_game_map_index_t tmpidx = 0; + unsigned int w = 29; + unsigned int h = 21; + unsigned int unitsize = 1; + + lash_mapSimpleInit(&map, &w, &h); + + lash_mapSimpleLayerPoke(map.layer_path, 50, 2); + lash_mapSimpleLayerPoke(map.layer_path, 80, 44); + for (tmpcoords.y=0; tmpcoords.y<h; tmpcoords.y++) { + for (tmpcoords.x=0; tmpcoords.x<w; tmpcoords.x++) { + lash_cartesianToIndex(&tmpidx, &w, &h, &unitsize, &tmpcoords); + printf("%02i ", lash_mapSimpleLayerPeek(map.layer_path, tmpidx)); + } + printf("\n"); + } + printf("\n"); + return 0; +} diff --git a/tests/mapclip.c b/tests/mapclip.c @@ -0,0 +1,92 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <math.h> +#include <unistd.h> +#include <time.h> + +#include "liblashgame/lash_game_map.h" +#include "liblashgame/lash_game_standard.h" + +#include "common.h" + +#define LASH_X_WIDTH 100 +#define LASH_X_HEIGHT 100 + +enum lash_game_map_clip_alignment { + LASH_GAME_MAP_CLIP_CENTER, + LASH_GAME_MAP_CLIP_TOPLEFT, + LASH_GAME_MAP_CLIP_BOTTOMLEFT, + LASH_GAME_MAP_CLIP_BOTTOMRIGHT, + LASH_GAME_MAP_CLIP_TOPRIGHT +}; + + + + +int main(int argc, char **argv) { + + unsigned int w = 0; + unsigned int h = 0; + char arg; + + time_t t; + + lash_game_map_index_t idx = 0; + + lash_map_simple_t map; + lash_map_simple_t clip; + + unsigned int clip_x_radius; + unsigned int clip_y_radius; + + // options + while ((arg = getopt(argc, argv, "w:h:x:y:i:")) != -1) { + switch(arg) { + case 'w': + w = atoi(optarg); + break; + case 'h': + h = atoi(optarg); + break; + case 'x': + clip_x_radius = atoi(optarg); + break; + case 'y': + clip_y_radius = atoi(optarg); + break; + case 'i': + idx = atoi(optarg); + break; + } + } + + w = w > 0 ? w : LASH_X_WIDTH; + h = h > 0 ? h : LASH_X_HEIGHT; + + // if clip is only one-dimensional, or same size as map + if (clip_x_radius == 0 || clip_y_radius == 0 || (clip_x_radius >= w && clip_y_radius >= h)) + return 1; + + //map = (lash_map_simple_t*)malloc(sizeof(lash_map_simple_t)); + //if (map == NULL) + // return 1; + + if (lash_mapSimpleInit(&map, &w, &h) == NULL) + return 1; + + srand((unsigned) time(&t)); + + fillMapRandom(&map, 64); + + if (lash_mapSimpleClip(&clip, &map, clip_x_radius, clip_y_radius, idx, LASH_GAME_MAP_OFFSET_CENTER, 1) == NULL) + return 1; + + dumpMapPathLayer(&clip, 1, -1, -1, -1); + dumpMapPathLayer(&map, 1, -1, -1, -1); + + lash_mapSimpleFree(&map); + lash_mapSimpleFree(&clip); + + return 0; +} diff --git a/tests/mapcolor.c b/tests/mapcolor.c @@ -0,0 +1,31 @@ +// test mapcolor + +#include "../lash_game_color.h" +#include "../lash_game_standard.h" +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) { + if (argc < 5) { + printf("Usage: %s r g b a\n", argv[0]); + return 1; + } + unsigned char r = (char)atoi(argv[1]); + unsigned char g = (char)atoi(argv[2]); + unsigned char b = (char)atoi(argv[3]); + unsigned char a = (char)atoi(argv[4]); + + union { + uint32_t color_int; + unsigned char color_bytes[4]; + } color; + + unsigned int i = lash_mapColor(r, g, b, a); + color.color_int = i; + + printf("Color given in RGBA: %03d %03d %03d %03d\n", r, g, b, a); + printf("Bytes stored in %p, order: %02X %03X %03X %03X\n", &color, color.color_bytes[0], color.color_bytes[1], color.color_bytes[2], color.color_bytes[3]); + printf("Int value is %d\n", color.color_int); + + return 0; +} diff --git a/tests/mapdata.txt b/tests/mapdata.txt @@ -0,0 +1,11 @@ +00 01 00 01 00 00 01 01 00 00 00 01 00 01 00 01 01 01 00 00 01 01 01 01 +01 00 00 00 00 01 01 00 00 01 00 01 01 00 00 00 00 01 00 01 00 01 00 01 +01 00 01 01 00 00 00 01 01 01 01 01 00 00 00 00 01 01 01 01 00 00 00 01 +00 01 01 00 00 00 00 00 00 00 01 01 01 00 01 00 00 00 01 01 00 01 01 01 +00 00 00 01 00 01 01 01 00 01 01 01 00 01 00 00 00 00 01 01 00 01 01 00 +01 00 01 00 01 00 01 01 01 01 01 01 01 01 01 00 00 01 00 00 00 01 00 01 +01 00 00 00 00 01 00 00 01 01 00 01 01 01 01 00 00 00 00 01 00 01 00 00 +00 00 00 00 00 01 00 00 01 01 00 00 01 00 00 00 00 00 00 01 01 00 01 01 +00 01 01 01 00 01 00 00 01 01 00 00 00 00 01 00 00 01 00 01 01 01 00 00 +01 01 01 00 01 00 00 01 01 01 00 00 00 01 01 01 00 00 00 00 01 01 00 00 +01 01 00 01 01 00 01 00 01 01 01 01 01 00 00 01 00 00 01 01 01 01 00 00 diff --git a/tests/mapdata_impossible.txt b/tests/mapdata_impossible.txt @@ -0,0 +1,50 @@ +00 00 01 00 00 00 00 01 00 00 00 01 00 00 00 01 01 00 00 00 01 01 00 01 00 01 01 00 00 00 00 00 01 01 01 01 00 01 01 00 01 01 01 01 01 00 01 00 00 01 +01 01 00 01 00 00 01 01 00 01 01 01 00 00 00 01 00 00 00 01 01 01 00 00 01 01 00 00 01 00 01 00 01 01 00 01 00 01 00 00 00 00 01 00 00 00 01 00 00 01 +01 01 01 01 00 00 00 00 00 00 01 01 00 00 00 00 00 00 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 00 00 00 00 01 01 00 01 00 01 01 00 00 00 00 00 01 +01 01 01 01 00 00 00 00 00 00 01 01 01 00 00 01 00 00 00 01 01 01 01 00 01 00 00 01 00 01 00 01 00 00 01 00 00 01 01 00 01 00 01 00 00 01 00 01 00 00 +00 01 00 00 01 01 00 00 00 00 01 00 00 01 00 01 00 00 00 01 00 00 01 00 00 00 01 00 01 01 01 01 00 01 01 00 00 01 00 00 00 01 00 00 00 01 01 00 01 01 +01 00 01 01 00 00 01 01 00 00 01 01 01 01 00 01 01 00 00 01 00 00 00 01 00 01 00 01 01 01 01 01 01 00 00 01 00 01 01 01 01 00 00 00 01 01 01 01 01 00 +00 00 00 01 01 01 00 01 00 01 00 01 00 00 00 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 00 01 00 01 00 01 00 00 00 00 00 01 00 00 01 00 01 00 00 00 +01 00 01 01 00 00 01 01 00 00 01 01 00 00 00 00 01 00 01 00 00 01 01 00 01 00 00 00 00 01 01 01 01 00 01 01 00 00 00 00 01 01 01 01 01 01 01 01 01 00 +01 00 01 00 00 01 00 01 01 00 00 00 00 01 00 01 00 00 01 00 01 00 01 00 01 01 00 01 00 01 01 01 01 01 01 00 00 01 01 01 01 01 00 01 00 00 00 00 01 00 +00 00 00 01 00 00 00 00 01 00 00 00 01 01 01 00 01 01 01 00 01 01 01 01 00 01 01 01 01 00 01 01 00 01 01 01 01 01 01 00 00 01 01 01 01 00 00 00 00 01 +01 01 00 00 00 01 00 01 00 01 00 01 01 00 00 00 01 00 01 01 00 01 00 01 01 01 00 01 00 00 00 01 01 01 01 01 00 01 00 00 01 00 01 00 01 01 00 00 01 01 +01 00 01 00 01 00 01 01 01 01 01 01 00 00 00 00 01 00 01 00 00 00 00 01 00 01 01 00 00 00 00 01 00 01 01 00 01 01 01 00 00 01 01 01 01 00 01 01 00 00 +01 01 01 01 00 01 01 01 00 01 00 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 01 01 01 00 00 00 01 01 00 01 00 01 01 00 00 01 00 00 01 01 -- 00 01 01 +00 01 01 01 01 01 01 00 01 01 00 01 01 01 00 01 01 00 00 00 01 00 01 01 01 00 01 01 00 00 01 00 00 00 01 01 01 01 01 00 00 00 01 01 01 01 01 00 00 01 +00 01 00 01 00 01 00 01 00 00 00 01 01 00 01 00 01 01 01 00 01 01 00 01 01 00 00 00 00 00 01 01 01 01 00 00 00 00 01 01 01 01 00 00 01 00 00 00 01 00 +01 00 01 01 01 00 01 00 00 00 00 00 01 00 01 01 00 00 00 01 01 01 01 01 01 00 01 01 01 00 01 00 01 01 01 00 01 01 00 00 01 01 00 00 01 01 01 01 01 01 +00 00 00 01 00 01 00 01 01 01 00 00 01 01 01 00 01 01 01 00 01 00 01 01 00 00 00 00 01 00 01 01 00 00 01 00 01 01 00 00 00 00 01 01 01 00 01 00 01 01 +00 00 01 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 01 00 01 00 01 00 01 00 00 00 01 01 01 01 00 00 01 00 00 01 00 00 00 00 01 00 01 00 01 01 +01 00 01 00 01 00 00 00 01 00 00 00 01 01 01 00 00 00 00 00 01 00 01 00 01 00 00 00 00 01 00 01 01 01 01 00 00 01 00 01 01 01 01 01 00 01 01 00 01 01 +01 01 01 00 01 00 00 01 01 00 00 01 01 01 00 00 00 00 01 00 01 00 01 01 01 00 00 00 00 01 01 01 00 01 01 01 01 01 00 00 01 00 01 00 00 00 00 00 00 01 +00 00 00 00 01 01 00 01 00 00 00 01 00 01 00 01 00 00 01 01 00 00 01 00 01 01 00 01 01 00 01 00 00 01 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 01 +01 01 01 01 01 00 00 01 00 00 01 01 00 00 00 00 01 00 00 00 01 00 01 01 01 01 01 01 01 00 00 01 01 01 00 00 00 00 01 00 00 00 01 00 00 01 00 00 01 00 +00 00 01 01 01 00 00 01 01 01 01 01 00 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 00 01 00 00 00 01 00 00 01 01 01 00 00 00 01 00 00 01 00 01 00 +01 01 00 00 01 00 00 01 00 00 01 01 00 00 01 01 00 01 00 01 00 01 01 00 00 01 01 01 01 00 00 00 01 00 00 00 00 01 00 00 01 01 00 00 01 01 01 01 01 00 +00 01 01 01 00 01 00 01 00 01 01 00 01 00 00 00 01 00 01 01 01 00 00 01 00 00 00 00 01 01 00 00 01 01 01 01 00 00 00 00 01 01 01 01 01 01 01 00 00 00 +01 01 00 00 00 01 00 00 01 01 00 01 01 01 00 01 00 00 01 00 00 00 01 01 01 00 01 00 01 01 00 00 00 01 00 00 00 00 00 01 00 00 00 01 01 00 00 01 00 01 +01 00 00 00 00 01 01 01 00 00 00 00 00 00 01 01 00 01 01 00 00 01 01 00 01 00 00 01 00 00 01 01 01 01 00 01 00 01 00 00 01 00 01 01 00 00 00 00 00 00 +00 00 01 01 01 00 00 01 00 00 00 01 01 01 00 01 00 00 00 00 01 01 00 00 01 00 00 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 00 01 00 00 01 00 01 01 +00 00 01 00 00 00 00 00 01 00 01 01 01 00 00 01 00 01 01 01 01 01 01 01 00 01 00 01 00 01 01 00 01 00 01 01 00 01 01 01 00 00 00 01 00 00 00 00 00 01 +00 01 00 01 00 00 00 00 00 00 01 01 01 00 01 00 01 01 01 01 00 01 01 01 00 00 01 00 00 01 01 00 00 01 01 01 00 00 01 00 00 01 01 01 01 00 01 01 01 01 +00 01 00 01 00 01 01 00 01 00 01 01 00 00 00 00 01 00 00 00 00 00 01 01 00 01 01 01 00 00 00 00 00 01 01 00 00 01 00 01 01 00 00 01 00 01 01 01 01 01 +01 00 00 01 01 00 00 01 01 00 01 00 00 01 01 01 00 01 00 00 00 01 00 01 01 00 00 00 01 01 00 01 01 00 00 01 00 00 00 01 00 01 01 00 01 00 01 01 01 00 +01 00 01 00 01 00 00 01 01 00 00 01 01 00 01 01 01 01 01 01 00 01 00 00 01 01 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 01 00 01 00 01 +00 01 00 01 01 01 00 01 00 01 01 00 01 01 00 01 00 01 01 00 00 00 01 01 01 01 00 00 01 01 01 01 00 00 00 01 01 01 00 01 00 00 00 01 01 00 00 00 01 01 +00 00 01 01 01 01 01 01 01 00 00 00 01 00 00 00 01 00 01 00 01 01 00 01 00 01 00 00 01 01 01 XX 01 01 01 00 00 00 00 01 00 00 01 00 01 00 00 00 00 01 +00 01 00 00 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 01 01 00 01 01 01 01 01 00 01 01 01 00 00 01 01 01 01 01 01 +00 01 01 01 00 01 01 01 01 01 00 00 00 00 01 00 00 00 01 00 01 00 01 01 01 00 00 00 00 00 01 00 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 01 01 +01 00 00 00 00 01 01 00 01 01 00 01 01 01 01 00 00 01 00 00 01 01 00 00 01 01 01 01 01 01 01 00 01 01 01 01 00 00 00 01 01 00 00 00 00 00 00 00 01 00 +01 00 01 01 00 01 00 00 00 00 01 01 00 00 00 01 00 00 01 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 01 00 01 00 00 01 00 01 01 00 00 01 00 00 00 01 +00 00 00 00 00 00 01 01 01 00 00 01 00 00 01 01 01 00 01 01 00 01 01 01 00 01 00 00 01 00 01 01 00 01 01 01 00 00 00 01 00 00 00 00 01 00 00 00 00 01 +01 00 01 00 01 01 01 00 01 00 00 00 01 01 00 01 00 00 01 00 01 00 00 01 00 01 01 00 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 01 01 01 00 01 01 01 +01 00 01 00 00 00 01 01 00 01 01 00 00 00 01 01 00 01 00 00 00 00 00 00 01 00 01 01 01 01 00 01 01 00 01 01 00 00 01 00 01 00 01 01 00 00 01 00 00 01 +00 00 01 01 00 00 01 00 01 00 01 00 01 00 00 00 00 00 01 01 00 00 01 01 00 00 00 01 00 00 00 01 00 00 00 01 00 01 01 00 01 00 00 01 00 00 01 00 00 00 +01 00 01 01 00 01 01 00 00 01 00 00 00 00 00 00 01 01 01 00 01 01 00 01 00 01 01 01 01 01 00 01 01 01 00 01 00 01 01 00 00 01 00 01 00 01 01 01 00 01 +00 01 00 00 00 00 01 01 01 01 00 01 00 01 00 00 01 00 01 00 00 01 00 01 00 00 00 00 01 00 01 01 01 01 00 01 01 01 00 00 00 00 00 00 01 00 00 00 01 01 +01 01 01 01 00 01 01 00 01 00 00 00 00 01 01 00 00 00 01 00 01 00 00 01 00 00 01 01 00 00 00 01 00 01 00 00 01 01 01 00 00 01 01 00 01 00 00 01 01 01 +00 00 01 00 01 00 00 00 01 01 01 01 00 01 01 01 01 00 00 00 00 00 00 01 00 01 00 00 00 01 00 00 01 01 01 00 01 01 00 00 00 01 00 01 00 01 00 00 01 00 +00 01 01 00 01 01 01 01 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01 00 01 00 00 01 01 01 00 01 00 00 00 01 00 01 01 00 01 01 00 00 01 00 01 00 01 +00 01 00 01 01 01 01 01 01 00 01 00 00 00 00 01 00 00 01 01 01 01 00 01 01 00 00 01 01 00 00 01 01 01 01 00 00 00 00 01 00 01 00 01 01 00 00 01 00 01 +00 00 00 00 01 01 00 01 01 01 01 01 00 00 00 01 01 00 01 01 00 00 00 00 01 01 00 01 00 01 00 00 01 00 00 00 01 00 01 00 01 00 00 01 00 00 01 01 01 00 diff --git a/tests/normalizequadrantradians.c b/tests/normalizequadrantradians.c @@ -0,0 +1,15 @@ +// normalize quadrant radians + +#include "../lash_game_standard.h" +#include <stdlib.h> +#include <stdio.h> + +int main(int argc, char *argv[]) { + if (argc < 2) { + printf("Usage: %s rads\n", argv[0]); + return 1; + } + + printf("%f\n", lash_normalizeQuadrantRadians(atof(argv[1]))); + return 0; +} diff --git a/tests/normalizeradians.c b/tests/normalizeradians.c @@ -0,0 +1,14 @@ +// normalize radians + +#include "../lash_game_standard.h" +#include <stdio.h> + +int main() { + printf("Normalize -2.7: %f\n", lash_normalizeRadians(-2.7)); + printf("Normalize -4.7: %f\n", lash_normalizeRadians(-4.7)); + printf("Normalize -9.7: %f\n", lash_normalizeRadians(-9.7)); + printf("Normalize 2.7: %f\n", lash_normalizeRadians(2.7)); + printf("Normalize 4.7: %f\n", lash_normalizeRadians(4.7)); + printf("Normalize 9.7: %f\n", lash_normalizeRadians(9.7)); + return 0; +} diff --git a/tests/pathcheckmodifier.c b/tests/pathcheckmodifier.c @@ -0,0 +1,48 @@ +// check modifier check + +#include <stdlib.h> +#include <stdio.h> +#include <time.h> +#include "../lash_game_path_simple.h" +#include "../lash_game_map.h" + +int main() { + clock_t test_clock_total = 0.f; + clock_t begin; + unsigned int w = 29; + unsigned int h = 21; + lash_path_simple_obstacle_t *o = (lash_path_simple_obstacle_t*)malloc(sizeof(lash_path_simple_obstacle_t)*3); + o->val = 1; + o->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL; + (o+1)->val = 2; + (o+1)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_HALF; + + lash_map_simple_t map; + lash_mapSimpleInit(&map, &w, &h); + lash_mapSimpleLayerPoke(map.layer_path, 10, 1); + lash_mapSimpleLayerPoke(map.layer_path, 20, 2); + lash_mapSimpleLayerPoke(map.layer_path, 30, 3); + + float r; + + begin = clock(); + r = lash_pathSimpleCheckModifier(&(map.layer_path + 10)->val, o, 2); + test_clock_total += clock() - begin; + printf("Check idx 10 content 1: %f\n", r); + + begin = clock(); + r = lash_pathSimpleCheckModifier(&(map.layer_path + 20)->val, o, 2); + test_clock_total += clock() - begin; + printf("Check idx 20 content 2: %f\n", r); + + begin = clock(); + r = lash_pathSimpleCheckModifier(&(map.layer_path + 30)->val, o, 2); + test_clock_total += clock() - begin; + printf("Check idx 30 content 3: %f\n", r); + + test_clock_total /= 3; + + printf("Total checktime (avg of 3): %lu ticks @ %li pr sec = %.7f secs\n\n", (long)test_clock_total, CLOCKS_PER_SEC, ((double)test_clock_total / CLOCKS_PER_SEC)); + + return 0; +} diff --git a/tests/pathfindfreesquare.c b/tests/pathfindfreesquare.c @@ -0,0 +1,247 @@ +#include "../lash_game_path.h" +#include "../lash_game_map.h" +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> + +void dumpspaces (lash_path_simple_t *path) { + int i; + printf("Spaces dump:\n"); + for (i = 0; i < path->spaces_position; i++) { + printf("%i=i%i,f%i ", i, (path->spaces+i)->index, (path->spaces+i)->f); + } + printf("\n"); +} + + +int dumptree(lash_tree_t *tree, char *treename) { + printf("Tree %s is now size %d: ", treename, tree->position); + int j; + //long int lastn = 0; + int falsesort = 0; + long int nn, nc; + unsigned int nl; + for (j = 1; j <= tree->position; j++) { + int ti = *(tree->idx + j - 1); + nn = *(tree->heap + ti); + nl = *(tree->local + ti); + nc = *(tree->heap + *(tree->idx + (int)(j / 2) - 1)); + printf("#%u:h%li,l%u ", j, nn, nl); + if (nn < nc && j > 1) + falsesort = 1; + } + if (falsesort == 1) { + printf("SORTERROR!\n"); + return 1; + } + printf("\n"); + return 0; +} + +void dumpmappathlayer(lash_map_simple_t *map, unsigned int unitsize, int position, int target, lash_path_simple_space_t *finalpath, unsigned int finalpathcount) { + lash_game_coords_t tmpcoords; + lash_game_map_index_t tmpidx; + for (tmpcoords.y = 0; tmpcoords.y < *map->h; tmpcoords.y++) { + for (tmpcoords.x = 0; tmpcoords.x < *map->w; tmpcoords.x++) { + lash_cartesianToIndex(&tmpidx, map->w, map->h, unitsize, &tmpcoords); + if (tmpidx == position) { + printf("XX "); + } else if (tmpidx == target) { + printf("-- "); + } else if (finalpath != NULL) { + int i = 0; + int onpath = 0; + for (i = 0; i <= finalpathcount; i++) { + if (tmpidx == (finalpath+i)->index && onpath == 0) { + printf(".. "); + onpath = 1; + } + } + if (onpath == 0) { + printf("%02i ", (int)lash_mapSimpleLayerPeek(map->layer_path, tmpidx)); + } + } else { + printf("%02i ", (int)lash_mapSimpleLayerPeek(map->layer_path, tmpidx)); + } + } + printf("\n"); + } + printf("\n"); +} + +int main(int argc, char **argv) { + + lash_map_simple_t map; + lash_path_simple_t path; + lash_path_simple_space_t *space; + + int w = -1; + int h = -1; + int idx = -1; + int r = -1; + char arg = -1; + + int i = 0; + int xclip = 0; + int yclip = 0; + + unsigned int indexunit; + unsigned int dleft; + unsigned int dright; + unsigned int dtop; + unsigned int dbottom; + + unsigned int ctop; + unsigned int cbottom; + unsigned int cleft; + unsigned int cright; + + unsigned int spacestotal; + lash_game_map_index_t *spaces; + unsigned int spacescount; + + lash_game_map_index_t target; + + unsigned char obstaclestotal = 2; + + lash_path_simple_obstacle_t *obstacles = (lash_path_simple_obstacle_t*)malloc(sizeof(lash_path_simple_obstacle_t) * 3); + obstacles->val = 0; + obstacles->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE; + (obstacles+1)->val = 1; + (obstacles+1)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL; + (obstacles+2)->val = 2; + (obstacles+2)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_HALF; + + lash_path_simple_space_t *finalpath; + + time_t t; + + srand((unsigned) time(&t)); + + while ((arg = getopt(argc, argv, "w:h:i:r:")) != -1) { + switch(arg) { + case 'w': + w = atoi(optarg); + break; + case 'h': + h = atoi(optarg); + break; + case 'i': + idx = atoi(optarg); + break; + case 'r': + r = atoi(optarg); + break; + } + } + + if (w < 0 || h < 0 || idx < 0 || r < 0) { + fprintf(stderr, "All options not set, exiting ...\n"); + return 1; + } + + printf("Width %d Height %d index %d radius %d\n", w, h, idx, r); + + lash_mapSimpleInit(&map, &w, &h); + + for (i = 0; i < w * h; i++) { + if (i != idx) + lash_mapSimpleLayerPoke(map.layer_path, i, rand() % 2); + } + + dumpmappathlayer(&map, 1, idx, -1, NULL, 0); + + dtop = (int)floor(idx / w); + dbottom = h - dtop - 1; + dleft = idx - dtop * w; + dright = ((dtop + 1) * w) - idx - 1; + + ctop = r > dtop ? dtop : r; + cbottom = r > dbottom ? dbottom : r; + cleft = r > dleft ? dleft : r; + cright = r > dright ? dright : r; + + spacestotal = (cright + cleft + 1) * (cbottom + ctop + 1); + + printf("Spaces to left edge %d clipping %d\n", dleft, cleft); + printf("Spaces to right edge %d clipping %d\n", dright, cright); + printf("Spaces to upper edge %d clipping %d\n", dtop, ctop); + printf("Spaces to lower edge %d clipping %d\n", dbottom, cbottom); + printf("Total spaces in clip %d\n", spacestotal); + + spaces = (lash_game_map_index_t*)malloc(sizeof(lash_game_map_index_t) * spacestotal); + spacescount = 0; + + for (yclip = idx - (ctop * w); yclip <= idx + (cbottom * w); yclip += w) { + for (xclip = yclip - cleft; xclip <= yclip + cright; xclip++) { + lash_map_simple_layer_item_t item = lash_mapSimpleLayerPeek(map.layer_path, xclip); + if (xclip == idx) { + printf("XX "); + } else { + printf("%.2d ", item); + + // here insert obstacleslist check + //if (item == 0) { + if (lash_pathSimpleCheckModifier(&item, obstacles, obstaclestotal) > 0.0) { + *(spaces + spacescount) = xclip; + spacescount++; + } else { + //fprintf(stderr, "item %d idx %d is impassable\n", item, xclip); + } + } + } + printf("\n"); + } + + // spacescount + 1 but original position is also reckoned not open + printf("Open spaces %d\n", spacescount); + + if (spacescount == 0) { + return 0; + } + + target = rand() % spacescount; + printf("Target pointer pos is %d\n", target); + printf("Target is %d\n", *(spaces + target)); + dumpmappathlayer(&map, 1, idx, *(spaces + target), NULL, 0); + + lash_pathSimpleInit(&path, &map, idx, *(spaces + target)); + space = lash_pathSimpleNext(&path); + space = lash_pathSimpleStepProcess(&path, &map, space, obstacles, obstaclestotal); + while (space->index != path.target) { + space = lash_pathSimpleStepProcess(&path, &map, space, obstacles, obstaclestotal); + if (space == NULL) { + printf("No path possible!!\n"); + break; + } + } + + i = 0; + + finalpath = (lash_path_simple_space_t*)malloc(sizeof(lash_path_simple_space_t) * (path.closedtree->position + 1)); + *(finalpath + 0) = *space; + if (finalpath->index != path.target) { + printf("No path possible!!\n"); + } else { + do { + space = (finalpath + i)->parent; + if (space != NULL) { + i++; + *(finalpath + i) = *space; + } + } while (space != NULL); + } + + dumpmappathlayer(&map, 1, idx, *(spaces + target), finalpath, i); + + + lash_pathSimpleFree(&path); + lash_mapSimpleFree(&map); + free(spaces); + free(finalpath); + free(obstacles); + + return 0; + +} + diff --git a/tests/pathsimple.c b/tests/pathsimple.c @@ -0,0 +1,40 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "../lash_game_path_simple.h" +#include "../../liblash/lash_tree3_dump.h" +#include "../../liblash/lash_tree3.h" +#include "../lash_game_map.h" + +int main() { + + lash_path_simple_t path; + lash_map_simple_t map; + lash_path_simple_space_t *space; + unsigned int w = 20; + unsigned int h = 10; + lash_game_map_index_t startindex = 50; + lash_game_map_index_t nextindex = 60; + lash_game_map_index_t endindex = 150; + lash_path_simple_space_t *resultspace; + + if (lash_mapSimpleInit(&map, &w, &h) == NULL) + return 1; + + lash_pathSimpleInit(); + + if (lash_pathSimpleNew(&path, &map, startindex, endindex) == NULL) + return 1; + + lash_pathSimpleNext(&path, &space); + _lash_pathSimpleClose(&path, *(path.opentree)->item); + resultspace = _lash_pathSimpleFindIndexInTree(path.closedtree, startindex); + + space = _lash_pathSimpleAddSpace(&path); + _lash_pathSimpleUpdateSpace(&path, space, resultspace, nextindex, resultspace->g + 14); + lash_treePush(path.opentree, space, NULL); + + resultspace = _lash_pathSimpleFindIndexInTree(path.opentree, nextindex); + + return 0; +} diff --git a/tests/pathsimpledemo.c b/tests/pathsimpledemo.c @@ -0,0 +1,357 @@ +#include "../lash_game_path_simple.h" +#include "../lash_game_map.h" +#include "../lash_game_standard.h" +#include "liblash/lash_tree3_dump.h" + +#include "liblash/lash_debug_timer.h" + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +#define LASH_X_TEST_COUNT 1000 + +int loadMap(char *filename, int *w, int *h, int *s, int *t, char **savemap) { + FILE *f; + size_t fpos; + + unsigned char buffer[1024]; + char *tmpmap; + + f = fopen(filename, "rb"); + + if (f == NULL) + return 1; + + fpos = fread(buffer, 1, 8, f); + + *w = (int)(buffer[0] | buffer[1] << 8); + *h = (int)(buffer[2] | buffer[3] << 8); + *s = (int)(buffer[4] | buffer[5] << 8); + *t = (int)(buffer[6] | buffer[7] << 8); + + tmpmap = (char*)calloc(*w * *h, sizeof(char)); + if (tmpmap == NULL) + return 1; + + fseek(f, fpos, SEEK_SET); + + fpos += fread(buffer, 1, (size_t)*w, f); + + // if data in file is not aligned to w this will cause a segfault + while (!feof(f)) { + memcpy((tmpmap + fpos - *w - 8), buffer, (size_t)*w); + fseek(f, fpos, SEEK_SET); + fpos += fread(buffer, 1, (size_t)*w, f); + + } + + fclose(f); + + *savemap = tmpmap; + + return 0; +} + +void freeMap(char *savemap) { + if (savemap != NULL) + free(savemap); +} + +void dumpmappathlayer(lash_map_simple_t *map, unsigned int unitsize, int start, int target, int position, lash_path_simple_space_t *finalpath, unsigned int finalpathcount) { + lash_game_coords_t tmpcoords; + lash_game_map_index_t tmpidx; + for (tmpcoords.y = 0; tmpcoords.y < *map->h; tmpcoords.y++) { + for (tmpcoords.x = 0; tmpcoords.x < *map->w; tmpcoords.x++) { + lash_cartesianToIndex(&tmpidx, map->w, map->h, &unitsize, &tmpcoords); + if (tmpidx == start) { + printf("XX "); + } else if (tmpidx == target) { + printf("-- "); + } else if (tmpidx == position) { + printf("?? "); + } else if (finalpath != NULL) { + int i = 0; + int onpath = 0; + for (i = 0; i <= finalpathcount; i++) { + if (tmpidx == (finalpath+i)->index && onpath == 0) { + printf(".. "); + onpath = 1; + } + } + if (onpath == 0) { + printf("%02i ", (int)lash_mapSimpleLayerPeek(map->layer_path, tmpidx)); + } + } else { + printf("%02i ", (int)lash_mapSimpleLayerPeek(map->layer_path, tmpidx)); + } + } + printf("\n"); + } + printf("\n"); + fflush(stdout); +} + +int main(int argc, char **argv) { + + lash_map_simple_t map; + lash_path_simple_t path; + lash_path_simple_space_t *space; + lash_debug_timer_t timer; + + int w = -1; + int h = -1; + int idx = -1; + int savedtarget = -1; + int r = -1; + char arg = -1; + char *filename = NULL; + + int i = 0; + int xclip = 0; + int yclip = 0; + + unsigned int indexunit; + unsigned int dleft; + unsigned int dright; + unsigned int dtop; + unsigned int dbottom; + + unsigned int ctop; + unsigned int cbottom; + unsigned int cleft; + unsigned int cright; + + unsigned int spacestotal; + lash_game_map_index_t *spaces; + unsigned int spacescount; + + unsigned int pathopenstepsresult; + int impossible = 0; + unsigned int attemptedsteps; + unsigned int testcount = LASH_X_TEST_COUNT; + + lash_game_map_index_t target; + lash_game_map_index_t targetglobalindex; + + char *savedmap = NULL; + + unsigned char obstaclestotal = 2; + + int dumpeverystep = 0; + + lash_path_simple_obstacle_t *obstacles = (lash_path_simple_obstacle_t*)malloc(sizeof(lash_path_simple_obstacle_t) * 3); + obstacles->val = 0; + obstacles->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE; + (obstacles+1)->val = 1; + (obstacles+1)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL; + (obstacles+2)->val = 2; + (obstacles+2)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_HALF; + + lash_path_simple_space_t *finalpath; + + time_t t; + + srand((unsigned) time(&t)); + + while ((arg = getopt(argc, argv, "w:h:i:r:f:c:d")) != -1) { + switch(arg) { + case 'w': + w = atoi(optarg); + break; + case 'h': + h = atoi(optarg); + break; + case 'i': + idx = atoi(optarg); + break; + case 'r': + r = atoi(optarg); + break; + case 'c': + testcount = atoi(optarg); + break; + case 'd': + dumpeverystep = 1; + break; + case 'f': + filename = optarg; + break; + } + } + + if (filename != NULL) { + if (strcmp(filename, "")) { + if (loadMap(filename, &w, &h, &idx, &savedtarget, &savedmap)) + return 1; + lash_mapSimpleInit(&map, &w, &h); + for (i = 0; i < w * h; i++) + lash_mapSimpleLayerPoke(map.layer_path, i, *(savedmap + i)); + } + } + + if (savedmap != NULL) { + freeMap(savedmap); + } else { + if (w < 0 || h < 0 || r < 0) { + fprintf(stderr, "All options not set, exiting ...\n"); + return 1; + } else { + lash_mapSimpleInit(&map, &w, &h); + + for (i = 0; i < w * h; i++) { + if (i != idx) + lash_mapSimpleLayerPoke(map.layer_path, i, rand() % 2); + } + } + } + + printf("Width %d Height %d index %d radius %d target %d\n", w, h, idx, r, savedtarget); + + // can potentially go on forever/for a long time if no/few vacant spaces are available + while (idx == -1) { + unsigned int trytarget = rand() % (w * h); + if (lash_mapSimpleLayerPeek(map.layer_path, trytarget) == 0) + idx = (int)trytarget; + } + + dumpmappathlayer(&map, 1, idx, -1, -1, NULL, 0); + + dtop = (int)floor(idx / w); + dbottom = h - dtop - 1; + dleft = idx - dtop * w; + dright = ((dtop + 1) * w) - idx - 1; + + ctop = r > dtop ? dtop : r; + cbottom = r > dbottom ? dbottom : r; + cleft = r > dleft ? dleft : r; + cright = r > dright ? dright : r; + + spacestotal = (cright + cleft + 1) * (cbottom + ctop + 1); + + printf("Spaces to left edge %d clipping %d\n", dleft, cleft); + printf("Spaces to right edge %d clipping %d\n", dright, cright); + printf("Spaces to upper edge %d clipping %d\n", dtop, ctop); + printf("Spaces to lower edge %d clipping %d\n", dbottom, cbottom); + printf("Total spaces in clip %d\n", spacestotal); + + spaces = (lash_game_map_index_t*)malloc(sizeof(lash_game_map_index_t) * spacestotal); + spacescount = 0; + + + + for (yclip = idx - (ctop * w); yclip <= idx + (cbottom * w); yclip += w) { + for (xclip = yclip - cleft; xclip <= yclip + cright; xclip++) { + lash_map_simple_layer_item_t item = lash_mapSimpleLayerPeek(map.layer_path, xclip); + if (xclip == idx) { + printf("XX "); + } else { + printf("%.2d ", item); + + // here insert obstacleslist check + //if (item == 0) { + if (lash_pathSimpleCheckModifier(&item, obstacles, obstaclestotal) > 0.0) { + *(spaces + spacescount) = xclip; + spacescount++; + } else { + //fprintf(stderr, "item %d idx %d is impassable\n", item, xclip); + } + } + } + printf("\n"); + } + + // spacescount + 1 but original position is also reckoned not open + printf("Open spaces %d\n", spacescount); + + if (spacescount == 0) { + return 0; + } + + if (savedtarget == -1) { + target = rand() % spacescount; + printf("Target pointer pos is %d\n", (int)target); + targetglobalindex = *(spaces + target); + } else { + printf("Target is global pointer pos %d (from saved file)\n", (int)savedtarget); + targetglobalindex = savedtarget; + } + + + printf("Target is %d\n", (int)targetglobalindex); + dumpmappathlayer(&map, 1, idx, targetglobalindex, -1, NULL, 0); + + // CALCULATE THE PATH + + lash_debugTimerReset(&timer); + + for (i = 0; i < testcount; i++) { + long ticksoutputcompensate = 0; + lash_pathSimpleInit(&path, &map, idx, targetglobalindex); + + lash_treeDumpInit(2); + lash_treeDumpAdd(path.opentree, "open"); + lash_treeDumpAdd(path.closedtree, "closed"); + + lash_pathSimpleNext(&path, &space); + //pathopenstepsresult = lash_pathSimpleStepProcess(&path, &map, space, obstacles, obstaclestotal); + + + attemptedsteps = 0; + lash_debugTimerStart(&timer); + while (space->index != path.target) { + + if (dumpeverystep && i == 0) { + lash_debugTimerPause(&timer); + printf("\ndumping idx %u\n", (unsigned int)space->index); + dumpmappathlayer(&map, 1, idx, targetglobalindex, space->index, NULL, 0); + lash_debugTimerPause(&timer); + } + + pathopenstepsresult = lash_pathSimpleStepProcess(&path, &map, space, obstacles, obstaclestotal); + attemptedsteps++; + lash_pathSimpleNext(&path, &space); + + if (space == NULL) { + impossible = 1; + break; + } + + } + lash_debugTimerStop(&timer); + } //for test count + + + printf("number of runs: %u\ntotal ticks: %li\naverage ticks: %i\nattempted steps: %u\n", timer.count, timer.total, lash_debugTimerGetAverage(&timer), attemptedsteps); + + i = 0; + + if (!impossible) { + finalpath = (lash_path_simple_space_t*)malloc(sizeof(lash_path_simple_space_t) * (path.closedtree->count + 1)); + *(finalpath + 0) = *space; + + do { + space = (finalpath + i)->parent; + if (space != NULL) { + i++; + *(finalpath + i) = *space; + } + } while (space != NULL); + + dumpmappathlayer(&map, 1, idx, targetglobalindex, -1, finalpath, i); + free(finalpath); + } else { + printf("No path possible!\n"); + } + + lash_pathSimpleFree(&path); + lash_mapSimpleFree(&map); + free(spaces); + free(obstacles); + + return 0; + +} + diff --git a/tests/polarcartesian.c b/tests/polarcartesian.c @@ -0,0 +1,26 @@ +// polartocartesian + +#include "../lash_game_standard.h" +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) { + if (argc < 5) { + printf("Usage: %s radians radius src_x src_y\n", argv[0]); + return 1; + } + + float radians = atof(argv[1]); + float radius = atof(argv[2]); + int16_t src_x = atoi(argv[3]); + int16_t src_y = atoi(argv[4]); + int target_x = 0.f; + int target_y = 0.f; + + lash_polarToCartesian(radians, radius, src_x, src_y, &target_x, &target_y); + + printf("Src: x%d,y%d\nRadians: %f\nRadius: %f\nResult: x%d,y%d\n", src_x, src_y, radians, radius, target_x, target_y); + + return 0; +} diff --git a/tests/surfacecollision.c b/tests/surfacecollision.c @@ -0,0 +1,24 @@ +// test lash_game_standard : lash_collisionSurfaceSimple() + +#include "../lash_game_standard.h" +#include <stdio.h> +#include <stdlib.h> +#include <math.h> + +int main(int argc, char *argv[]) { + if (argc < 5) { + printf("Usage: %s obj_vel obj_rad_in_degrees surface_rad_in_degrees bounce_factor\n", argv[0]); + return 1; + } + + float objv = atof(argv[1]); + float objr = (atof(argv[2]) * M_PI) / 180.f; + float surr = (atof(argv[3]) * M_PI) / 180.f; + float bounce = atof(argv[4]); + + lash_collisionSurfaceDeflectSimple(&objv, &objr, surr, bounce); + + printf("velocity %f, degrees %f\n", objv, (lash_normalizeRadians(objr) * 180) / M_PI); + + return 0; +}