summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/helpers.hpp18
-rw-r--r--src/rail.h4
-rw-r--r--src/rail_cmd.cpp6
-rw-r--r--src/town_cmd.cpp2
4 files changed, 12 insertions, 18 deletions
diff --git a/src/helpers.hpp b/src/helpers.hpp
index 5f378803a..fb5aeb5f8 100644
--- a/src/helpers.hpp
+++ b/src/helpers.hpp
@@ -138,25 +138,19 @@ template <typename Tenum_t> struct TinyEnumT
}
};
-template <typename T> FORCEINLINE T ClrBitT(T t, int bit_index)
+template <typename T> void ClrBitT(T &t, int bit_index)
{
- int val = t;
- CLRBIT(val, bit_index);
- return (T)val;
+ t = (T)(t & ~((T)1 << bit_index));
}
-template <typename T> FORCEINLINE T SetBitT(T t, int bit_index)
+template <typename T> void SetBitT(T &t, int bit_index)
{
- int val = t;
- SETBIT(val, bit_index);
- return (T)val;
+ t = (T)(t | ((T)1 << bit_index));
}
-template <typename T> FORCEINLINE T ToggleBitT(T t, int bit_index)
+template <typename T> void ToggleBitT(T &t, int bit_index)
{
- int val = t;
- TOGGLEBIT(val, bit_index);
- return (T)val;
+ t = (T)(t ^ ((T)1 << bit_index));
}
#endif /* HELPERS_HPP */
diff --git a/src/rail.h b/src/rail.h
index ae651ebe5..7f3d4330d 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -261,7 +261,7 @@ static inline Track RemoveFirstTrack(TrackBits *tracks)
{
if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) {
Track first = (Track)FIND_FIRST_BIT(*tracks);
- *tracks = ClrBitT(*tracks, first);
+ ClrBitT(*tracks, first);
return first;
}
return INVALID_TRACK;
@@ -274,7 +274,7 @@ static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
{
if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) {
Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs);
- *trackdirs = ClrBitT(*trackdirs, first);
+ ClrBitT(*trackdirs, first);
return first;
}
return INVALID_TRACKDIR;
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 18eb0f1d0..437d19463 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -450,7 +450,7 @@ static int32 ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileIndex end
(trdy >= 0 && dy < 0)
) {
if (!HASBIT(*trackdir, 3)) { // first direction is invalid, try the other
- *trackdir = SetBitT(*trackdir, 3); // reverse the direction
+ SetBitT(*trackdir, 3); // reverse the direction
trdx = -trdx;
trdy = -trdy;
} else { // other direction is invalid too, invalid drag
@@ -513,7 +513,7 @@ static int32 CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32
tile += ToTileIndexDiff(_trackdelta[trackdir]);
// toggle railbit for the non-diagonal tracks
- if (!IsDiagonalTrackdir(trackdir)) trackdir = ToggleBitT(trackdir, 0);
+ if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0);
}
return (total_cost == 0) ? CMD_ERROR : total_cost;
@@ -777,7 +777,7 @@ static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint3
signal_ctr++;
// toggle railbit for the non-diagonal tracks (|, -- tracks)
- if (!IsDiagonalTrackdir(trackdir)) trackdir = ToggleBitT(trackdir, 0);
+ if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0);
}
return error ? CMD_ERROR : total_cost;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index b79b5e211..dd5da52fe 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -730,7 +730,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
// Exclude the source position from the bitmask
// and return if no more road blocks available
- mask = ClrBitT(mask, (block ^ 2));
+ ClrBitT(mask, (block ^ 2));
if (mask == 0)
return _grow_town_result;