Skip to content

Commit

Permalink
Allow transporters to unload near cliffs.
Browse files Browse the repository at this point in the history
This way, unloading a transporter is less likely to result in the droids getting unloaded some random place 20 tiles away.
  • Loading branch information
Cyp committed Dec 16, 2011
1 parent 66e4291 commit 1646499
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 59 deletions.
35 changes: 0 additions & 35 deletions src/droid.cpp
Expand Up @@ -3160,47 +3160,18 @@ static bool oneDroidMax(UDWORD x, UDWORD y)
// returns true if it's a sensible place to put that droid.
static bool sensiblePlace(SDWORD x, SDWORD y, PROPULSION_TYPE propulsion)
{
UDWORD count=0;

// not too near the edges.
if((x < TOO_NEAR_EDGE) || (x > (SDWORD)(mapWidth - TOO_NEAR_EDGE)))
return false;
if((y < TOO_NEAR_EDGE) || (y > (SDWORD)(mapHeight - TOO_NEAR_EDGE)))
return false;

// check no features there
if(TileHasFeature(mapTile(x,y)))
{
return false;
}

// not on a blocking tile.
if (fpathBlockingTile(x, y, propulsion))
{
return false;
}

// shouldn't next to more than one blocking tile, to avoid windy paths.
if (fpathBlockingTile(x - 1, y - 1, propulsion))
count++;
if (fpathBlockingTile(x, y - 1, propulsion))
count++;
if (fpathBlockingTile(x + 1, y - 1, propulsion))
count++;
if (fpathBlockingTile(x - 1, y, propulsion))
count++;
if (fpathBlockingTile(x + 1, y, propulsion))
count++;
if (fpathBlockingTile(x -1, y + 1, propulsion))
count++;
if (fpathBlockingTile(x, y + 1, propulsion))
count++;
if (fpathBlockingTile(x +1, y + 1, propulsion))
count++;

if(count > 1)
return false;

return true;
}

Expand Down Expand Up @@ -3284,12 +3255,6 @@ bool pickATileGenThreat(UDWORD *x, UDWORD *y, UBYTE numIterations, SDWORD threat

}

/// find an empty tile accessible to a wheeled droid
bool pickATile(UDWORD *x, UDWORD *y, UBYTE numIterations)
{
return pickATileGen(x, y, numIterations, zonedPAT);
}

/// find a tile for a wheeled droid with only one other droid present
PICKTILE pickHalfATile(UDWORD *x, UDWORD *y, UBYTE numIterations)
{
Expand Down
5 changes: 1 addition & 4 deletions src/droid.h
Expand Up @@ -48,7 +48,7 @@
extern DROID_TEMPLATE *apsDroidTemplates[MAX_PLAYERS];
extern DROID_TEMPLATE *apsStaticTemplates; // for AIs and scripts

//used to stop structures being built too near the edge and droids being placed down - pickATile
//used to stop structures being built too near the edge and droids being placed down
#define TOO_NEAR_EDGE 3

/* Define max number of allowed droids per droid type */
Expand All @@ -70,7 +70,6 @@ enum PICKTILE
{
NO_FREE_TILE,
FREE_TILE,
HALF_FREE_TILE
};

// the structure that was last hit
Expand Down Expand Up @@ -248,9 +247,7 @@ extern void droidSetName(DROID *psDroid, const char *pName);
// returns true when no droid on x,y square.
extern bool noDroid (UDWORD x, UDWORD y); // true if no droid at x,y
// returns an x/y coord to place a droid
extern bool pickATile (UDWORD *x0,UDWORD *y0, UBYTE numIterations);
extern PICKTILE pickHalfATile (UDWORD *x, UDWORD *y, UBYTE numIterations);
extern bool pickATile2 (UDWORD *x, UDWORD *y, UDWORD numIterations);
extern bool zonedPAT(UDWORD x, UDWORD y);
extern bool pickATileGen(UDWORD *x, UDWORD *y, UBYTE numIterations,
bool (*function)(UDWORD x, UDWORD y));
Expand Down
20 changes: 0 additions & 20 deletions src/mission.cpp
Expand Up @@ -1022,11 +1022,6 @@ void placeLimboDroids(void)
}
psDroid->pos.x = (UWORD)world_coord(droidX);
psDroid->pos.y = (UWORD)world_coord(droidY);
if (pickRes == HALF_FREE_TILE )
{
psDroid->pos.x += TILE_UNITS;
psDroid->pos.y += TILE_UNITS;
}
ASSERT(worldOnMap(psDroid->pos.x,psDroid->pos.y), "limbo droid is not on the map");
psDroid->pos.z = map_Height(psDroid->pos.x, psDroid->pos.y);
updateDroidOrientation(psDroid);
Expand Down Expand Up @@ -1379,11 +1374,6 @@ static void processMission(void)
ASSERT(pickRes != NO_FREE_TILE, "processMission: Unable to find a free location" );
x = (UWORD)world_coord(droidX);
y = (UWORD)world_coord(droidY);
if (pickRes == HALF_FREE_TILE )
{
x += TILE_UNITS;
y += TILE_UNITS;
}
droidSetPosition(psDroid, x, y);
ASSERT(worldOnMap(psDroid->pos.x,psDroid->pos.y), "the droid is not on the map");
updateDroidOrientation(psDroid);
Expand Down Expand Up @@ -1745,11 +1735,6 @@ static void missionResetDroids(void)
int wx = world_coord(x);
int wy = world_coord(y);

if (pickRes == HALF_FREE_TILE )
{
wx += TILE_UNITS;
wy += TILE_UNITS;
}
droidSetPosition(psDroid, wx, wy);
placed = true;
}
Expand All @@ -1774,11 +1759,6 @@ static void missionResetDroids(void)
int wx = world_coord(x);
int wy = world_coord(y);

if (pickRes == HALF_FREE_TILE )
{
wx += TILE_UNITS;
wy += TILE_UNITS;
}
droidSetPosition(psDroid, wx, wy);
placed = true;
}
Expand Down

0 comments on commit 1646499

Please sign in to comment.