diff options
author | tron <tron@openttd.org> | 2007-01-19 11:47:48 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2007-01-19 11:47:48 +0000 |
commit | b2def962481476a5fae92f8539e5f061022bf442 (patch) | |
tree | b99fe1407a3f7165356bacf607eb1e59804164a9 /src/train_cmd.cpp | |
parent | 7af3094bc3cad9ba1182e7a68efa86c4239d4363 (diff) | |
download | openttd-b2def962481476a5fae92f8539e5f061022bf442.tar.xz |
(svn r8276) -Fix
Change the signature of Swap() to be less error prone, i.e. pass the variables to be swapped by reference instead of passing pointers to the variables.
Just do Swap(x, y) instead of Swap(&x, &y). This prevents accidents when the variables are pointers.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 00c998f8d..750745081 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1594,19 +1594,17 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r) a->vehstatus = tmp; } - /* swap variables */ - SwapT(&a->u.rail.track, &b->u.rail.track); - SwapT(&a->direction, &b->direction); + Swap(a->u.rail.track, b->u.rail.track); + Swap(a->direction, b->direction); /* toggle direction */ if (!(a->u.rail.track & 0x80)) a->direction = ReverseDir(a->direction); if (!(b->u.rail.track & 0x80)) b->direction = ReverseDir(b->direction); - /* swap more variables */ - SwapT(&a->x_pos, &b->x_pos); - SwapT(&a->y_pos, &b->y_pos); - SwapT(&a->tile, &b->tile); - SwapT(&a->z_pos, &b->z_pos); + Swap(a->x_pos, b->x_pos); + Swap(a->y_pos, b->y_pos); + Swap(a->tile, b->tile); + Swap(a->z_pos, b->z_pos); SwapTrainFlags(&a->u.rail.flags, &b->u.rail.flags); |