From 84a16a0b30c3c8f1df9a3e9fa8c2bb1e88199403 Mon Sep 17 00:00:00 2001 From: tron Date: Tue, 15 Nov 2005 08:49:46 +0000 Subject: [PATCH] (svn r3184) GB/SB --- disaster_cmd.c | 4 ++-- economy.c | 4 ++-- player_gui.c | 2 +- rail_cmd.c | 4 ++-- station_cmd.c | 4 ++-- tunnelbridge_cmd.c | 4 ++-- widget.c | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/disaster_cmd.c b/disaster_cmd.c index 601bc641e0..1f4c720983 100644 --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -666,7 +666,7 @@ static void DisasterTick_5_and_6(Vehicle *v) return; } - v->direction = (v->direction + ((Random()&1)?2:-2))&7; + v->direction = (v->direction + (GB(Random(), 0, 1) ? 2 : -2)) & 7; } @@ -902,9 +902,9 @@ static void Disaster6_Init(void) static void Disaster7_Init(void) { + int index = GB(Random(), 0, 4); Industry *i; int maxloop = 15; - int index = Random() & 0xF; do { FOR_ALL_INDUSTRIES(i) { diff --git a/economy.c b/economy.c index c9fcc4157b..04aa5ad05e 100644 --- a/economy.c +++ b/economy.c @@ -694,10 +694,10 @@ static void HandleEconomyFluctuations(void) if (_opt.diff.economy == 0) return; if (--_economy.fluct == 0) { - _economy.fluct = - (int)(Random()&3); + _economy.fluct = -(int)GB(Random(), 0, 2); AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0); } else if (_economy.fluct == -12) { - _economy.fluct = (Random()&255) + 312; + _economy.fluct = GB(Random(), 0, 8) + 312; AddNewsItem(STR_7074_RECESSION_OVER_UPTURN_IN, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0); } } diff --git a/player_gui.c b/player_gui.c index eba18b1430..3d97a2612e 100644 --- a/player_gui.c +++ b/player_gui.c @@ -342,7 +342,7 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e) SetWindowDirty(w); break; case 7: - WP(w,facesel_d).face = (InteractiveRandom() & 0x7FFFFFFF) + (WP(w,facesel_d).gender << 31); + WP(w,facesel_d).face = (WP(w,facesel_d).gender << 31) + GB(InteractiveRandom(), 0, 31); SetWindowDirty(w); break; } diff --git a/rail_cmd.c b/rail_cmd.c index 9b39295b85..45021856af 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -2064,8 +2064,8 @@ static void TileLoop_Track(TileIndex tile) modify_me:; /* tile changed? */ - if ( m2 != a2) { - _m[tile].m2 = (_m[tile].m2 & ~RAIL_MAP2LO_GROUND_MASK) | a2; + if (m2 != a2) { + SB(_m[tile].m2, 0, 4, a2); MarkTileDirtyByTile(tile); } } diff --git a/station_cmd.c b/station_cmd.c index e037e50818..2c98db2579 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -3016,8 +3016,8 @@ static void Load_STNS(void) // this means it's an oldstyle savegame without support for nonuniform stations if (st->train_tile != 0 && st->trainst_h == 0) { - int w = st->trainst_w >> 4; - int h = st->trainst_w & 0xF; + int w = GB(st->trainst_w, 4, 4); + int h = GB(st->trainst_w, 0, 4); if (_m[st->train_tile].m5 & 1) intswap(w, h); st->trainst_w = w; diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index ff8791f0fd..b37de55112 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -964,7 +964,7 @@ static void DrawBridgePillars(const TileInfo *ti, int x, int y, int z) // Draw first piece // (necessary for cantilever bridges) - image = b[12 + (ti->map5&0x01)]; + image = b[12 + GB(ti->map5, 0, 1)]; piece = GetBridgePiece(ti->tile); if (image != 0 && piece != 0) { @@ -972,7 +972,7 @@ static void DrawBridgePillars(const TileInfo *ti, int x, int y, int z) DrawGroundSpriteAt(image, x, y, z); } - image = b[(ti->map5&0x01)*6 + piece]; + image = b[GB(ti->map5, 0, 1) * 6 + piece]; if (image != 0) { int back_height, front_height, i=z; diff --git a/widget.c b/widget.c index 674f1279e6..acd401235b 100644 --- a/widget.c +++ b/widget.c @@ -223,10 +223,10 @@ void DrawWindowWidgets(const Window *w) DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); - c = (wi->unkA&0xFF); + c = GB(wi->unkA, 0, 8); amt1 = (wi->right - wi->left + 1) / c; - d = (wi->unkA >> 8); + d = GB(wi->unkA, 8, 8); amt2 = (wi->bottom - wi->top + 1) / d; color = _color_list[wi->color & 0xF].window_color_bgb;