(svn r11526) -Codechange: Rename the function delta fitting to the naming style

pull/155/head
skidd13 17 years ago
parent 91152b925e
commit f56579e0d9

@ -175,7 +175,7 @@ static inline int32 ClampToI32(const int64 a)
* @param b The second scalar
* @return The absolute difference between the given scalars
*/
template <typename T> static inline T delta(const T a, const T b) {
template <typename T> static inline T Delta(const T a, const T b) {
return (a < b) ? b - a : a - b;
}

@ -311,7 +311,7 @@ static void DisasterTick_Ufo(Vehicle *v)
/* Fly around randomly */
int x = TileX(v->dest_tile) * TILE_SIZE;
int y = TileY(v->dest_tile) * TILE_SIZE;
if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) {
if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) {
v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@ -340,7 +340,7 @@ static void DisasterTick_Ufo(Vehicle *v)
return;
}
dist = delta(v->x_pos, u->x_pos) + delta(v->y_pos, u->y_pos);
dist = Delta(v->x_pos, u->x_pos) + Delta(v->y_pos, u->y_pos);
if (dist < TILE_SIZE && !(u->vehstatus & VS_HIDDEN) && u->breakdown_ctr == 0) {
u->breakdown_ctr = 3;
@ -567,7 +567,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
if (v->current_order.dest == 1) {
int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
if (delta(v->x_pos, x) + delta(v->y_pos, y) >= 8) {
if (Delta(v->x_pos, x) + Delta(v->y_pos, y) >= 8) {
v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
@ -585,7 +585,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
FOR_ALL_VEHICLES(u) {
if (u->type == VEH_TRAIN || u->type == VEH_ROAD) {
if (delta(u->x_pos, v->x_pos) + delta(u->y_pos, v->y_pos) <= 12 * TILE_SIZE) {
if (Delta(u->x_pos, v->x_pos) + Delta(u->y_pos, v->y_pos) <= 12 * TILE_SIZE) {
u->breakdown_ctr = 5;
u->breakdown_delay = 0xF0;
}
@ -617,7 +617,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
} else if (v->current_order.dest == 0) {
int x = TileX(v->dest_tile) * TILE_SIZE;
int y = TileY(v->dest_tile) * TILE_SIZE;
if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) {
if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) {
v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@ -667,7 +667,7 @@ static void DisasterTick_Big_Ufo_Destroyer(Vehicle *v)
if (v->current_order.dest == 0) {
u = GetVehicle(v->u.disaster.big_ufo_destroyer_target);
if (delta(v->x_pos, u->x_pos) > TILE_SIZE) return;
if (Delta(v->x_pos, u->x_pos) > TILE_SIZE) return;
v->current_order.dest = 1;
CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);

@ -1290,7 +1290,7 @@ static bool CheckCanTerraformSurroundingTiles(TileIndex tile, uint height, int i
return false;
/* Don't allow too big of a change if this is the sub-tile check */
if (internal != 0 && delta(curh, height) > 1) return false;
if (internal != 0 && Delta(curh, height) > 1) return false;
/* Different height, so the surrounding tiles of this tile
* has to be correct too (in level, or almost in level)

@ -184,8 +184,8 @@ extern const TileIndexDiffC _tileoffs_by_dir[] = {
*/
uint DistanceManhattan(TileIndex t0, TileIndex t1)
{
const uint dx = delta(TileX(t0), TileX(t1));
const uint dy = delta(TileY(t0), TileY(t1));
const uint dx = Delta(TileX(t0), TileX(t1));
const uint dy = Delta(TileY(t0), TileY(t1));
return dx + dy;
}
@ -216,8 +216,8 @@ uint DistanceSquare(TileIndex t0, TileIndex t1)
*/
uint DistanceMax(TileIndex t0, TileIndex t1)
{
const uint dx = delta(TileX(t0), TileX(t1));
const uint dy = delta(TileY(t0), TileY(t1));
const uint dx = Delta(TileX(t0), TileX(t1));
const uint dy = Delta(TileY(t0), TileY(t1));
return max(dx, dy);
}
@ -232,8 +232,8 @@ uint DistanceMax(TileIndex t0, TileIndex t1)
*/
uint DistanceMaxPlusManhattan(TileIndex t0, TileIndex t1)
{
const uint dx = delta(TileX(t0), TileX(t1));
const uint dy = delta(TileY(t0), TileY(t1));
const uint dx = Delta(TileX(t0), TileX(t1));
const uint dy = Delta(TileY(t0), TileY(t1));
return dx > dy ? 2 * dx + dy : 2 * dy + dx;
}

@ -220,7 +220,7 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
if (w->viewport != NULL)
w->viewport->top += y - w->top;
diff = delta(w->top, y);
diff = Delta(w->top, y);
w->top = y;
SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);

@ -40,8 +40,8 @@ static const uint _trackdir_length[TRACKDIR_END] = {
*/
static uint NPFDistanceTrack(TileIndex t0, TileIndex t1)
{
const uint dx = delta(TileX(t0), TileX(t1));
const uint dy = delta(TileY(t0), TileY(t1));
const uint dx = Delta(TileX(t0), TileX(t1));
const uint dy = Delta(TileY(t0), TileY(t1));
const uint straightTracks = 2 * min(dx, dy); /* The number of straight (not full length) tracks */
/* OPTIMISATION:

@ -663,8 +663,8 @@ static const uint16 _is_upwards_slope[15] = {
static uint DistanceMoo(TileIndex t0, TileIndex t1)
{
const uint dx = delta(TileX(t0), TileX(t1));
const uint dy = delta(TileY(t0), TileY(t1));
const uint dx = Delta(TileX(t0), TileX(t1));
const uint dy = Delta(TileY(t0), TileY(t1));
const uint straightTracks = 2 * min(dx, dy); // The number of straight (not full length) tracks
/* OPTIMISATION:

@ -164,7 +164,7 @@ void PlaceTreeAtSameHeight(TileIndex tile, uint height)
continue;
/* Not too much height difference */
if (delta(GetTileZ(cur_tile), height) > 2) continue;
if (Delta(GetTileZ(cur_tile), height) > 2) continue;
/* Place one tree and quit */
PlaceTree(cur_tile, r);

@ -967,7 +967,7 @@ static void DrawTileSelection(const TileInfo *ti)
side = 0;
} else {
TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y);
side = delta(delta(TileX(start), TileX(ti->tile)), delta(TileY(start), TileY(ti->tile)));
side = Delta(Delta(TileX(start), TileX(ti->tile)), Delta(TileY(start), TileY(ti->tile)));
}
DrawAutorailSelection(ti, _AutorailType[dir][side]);
@ -2730,8 +2730,8 @@ calc_heightdiff_single_direction:;
TileIndex t0 = TileVirtXY(sx, sy);
TileIndex t1 = TileVirtXY(x, y);
uint dx = delta(TileX(t0), TileX(t1)) + 1;
uint dy = delta(TileY(t0), TileY(t1)) + 1;
uint dx = Delta(TileX(t0), TileX(t1)) + 1;
uint dy = Delta(TileY(t0), TileY(t1)) + 1;
byte index = 0;
uint64 params[3];

Loading…
Cancel
Save