1
0
Fork 0

(svn r2660) Get rid of some more shifting/anding/casting

release/0.4.5
tron 2005-07-21 06:31:02 +00:00
parent 5c5840417e
commit d71788c402
16 changed files with 74 additions and 75 deletions

View File

@ -742,7 +742,7 @@ static void TileLoop_Clear(TileIndex tile)
} }
/* did overflow, so continue */ /* did overflow, so continue */
} else { } else {
m5 = ((byte)Random() > 21) ? (2) : (6); m5 = (GB(Random(), 0, 8) > 21) ? 2 : 6;
} }
m5++; m5++;
} else if (_game_mode != GM_EDITOR) { } else if (_game_mode != GM_EDITOR) {
@ -767,29 +767,27 @@ static void TileLoop_Clear(TileIndex tile)
void GenerateClearTile(void) void GenerateClearTile(void)
{ {
int i,j; uint i;
TileIndex tile; TileIndex tile;
uint32 r;
/* add hills */ /* add hills */
i = ScaleByMapSize((Random() & 0x3FF) + 0x400); i = ScaleByMapSize((Random() & 0x3FF) + 0x400);
do { do {
tile = RandomTile(); tile = RandomTile();
if (IsTileType(tile, MP_CLEAR)) if (IsTileType(tile, MP_CLEAR)) SB(_m[tile].m5, 2, 2, 1);
_m[tile].m5 = (byte)((_m[tile].m5 & ~(3<<2)) | (1<<2));
} while (--i); } while (--i);
/* add grey squares */ /* add grey squares */
i = ScaleByMapSize((Random() & 0x7F) + 0x80); i = ScaleByMapSize((Random() & 0x7F) + 0x80);
do { do {
r = Random(); uint32 r = Random();
tile = RandomTileSeed(r); tile = RandomTileSeed(r);
if (IsTileType(tile, MP_CLEAR)) { if (IsTileType(tile, MP_CLEAR)) {
j = GB(r, 16, 4) + 5; uint j = GB(r, 16, 4) + 5;
for(;;) { for(;;) {
TileIndex tile_new; TileIndex tile_new;
_m[tile].m5 = (byte)((_m[tile].m5 & ~(3<<2)) | (2<<2)); SB(_m[tile].m5, 2, 2, 2);
do { do {
if (--j == 0) goto get_out; if (--j == 0) goto get_out;
tile_new = tile + TileOffsByDir(Random() & 3); tile_new = tile + TileOffsByDir(Random() & 3);

View File

@ -787,7 +787,7 @@ void StartupEconomy(void)
_economy.infl_amount = _opt.diff.initial_interest; _economy.infl_amount = _opt.diff.initial_interest;
_economy.infl_amount_pr = max(0, _opt.diff.initial_interest - 1); _economy.infl_amount_pr = max(0, _opt.diff.initial_interest - 1);
_economy.max_loan_unround = _economy.max_loan = _opt.diff.max_loan * 1000; _economy.max_loan_unround = _economy.max_loan = _opt.diff.max_loan * 1000;
_economy.fluct = (byte)(Random()) + 168; _economy.fluct = GB(Random(), 0, 8) + 168;
} }
Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode) Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode)

View File

@ -960,8 +960,8 @@ static void PlantFarmField(TileIndex tile)
/* determine field size */ /* determine field size */
r = (Random() & 0x303) + 0x404; r = (Random() & 0x303) + 0x404;
if (_opt.landscape == LT_HILLY) r += 0x404; if (_opt.landscape == LT_HILLY) r += 0x404;
size_x = (byte)r; size_x = GB(r, 0, 8);
size_y = r >> 8; size_y = GB(r, 8, 8);
/* offset tile to match size */ /* offset tile to match size */
tile -= TileDiffXY(size_x / 2, size_y / 2); tile -= TileDiffXY(size_x / 2, size_y / 2);
@ -977,7 +977,7 @@ static void PlantFarmField(TileIndex tile)
/* determine type of field */ /* determine type of field */
r = Random(); r = Random();
type = ((r & 0xE0) | 0xF); type = ((r & 0xE0) | 0xF);
type2 = ((byte)(r >> 8) * 9) >> 8; type2 = GB(r, 8, 8) * 9 >> 8;
/* make field */ /* make field */
BEGIN_TILE_LOOP(cur_tile, size_x, size_y, tile) BEGIN_TILE_LOOP(cur_tile, size_x, size_y, tile)

View File

@ -685,8 +685,8 @@ TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng)
uint32 r = Random(); uint32 r = Random();
return TILE_MASK(TileXY( return TILE_MASK(TileXY(
TileX(a) + ((byte)r * rn * 2 >> 8) - rn, TileX(a) + (GB(r, 0, 8) * rn * 2 >> 8) - rn,
TileY(a) + ((byte)(r >> 8) * rn * 2 >> 8) - rn TileY(a) + (GB(r, 8, 8) * rn * 2 >> 8) - rn
)); ));
} }

View File

@ -502,7 +502,7 @@ static void MenuWndProc(Window *w, WindowEvent *e)
do { do {
if (sel== 0) GfxFillRect(x, y, x + eo, y+9, 0); if (sel== 0) GfxFillRect(x, y, x + eo, y+9, 0);
DrawString(x + 2, y, (StringID)(string + (chk&1)), (byte)(sel==0?(byte)0xC:(byte)0x10)); DrawString(x + 2, y, string + (chk & 1), sel == 0 ? 0xC : 0x10);
y += 10; y += 10;
string += inc; string += inc;
chk >>= 1; chk >>= 1;
@ -642,7 +642,7 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
SetDParam(1, p->name_2); SetDParam(1, p->name_2);
SetDParam(2, GetPlayerNameString(p->index, 3)); SetDParam(2, GetPlayerNameString(p->index, 3));
color = (byte)((p->index==sel) ? 0xC : 0x10); color = (p->index == sel) ? 0xC : 0x10;
if (chk&1) color = 14; if (chk&1) color = 14;
DrawString(x + 19, y, STR_7021, color); DrawString(x + 19, y, STR_7021, color);

View File

@ -32,9 +32,10 @@ int32 CmdSetPlayerFace(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2) int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{ {
Player *p, *pp; Player *p, *pp;
byte colour = (byte)p2; byte colour;
if (p2 >= 16) return CMD_ERROR; // max 16 colours if (p2 >= 16) return CMD_ERROR; // max 16 colours
colour = p2;
p = GetPlayer(_current_player); p = GetPlayer(_current_player);

View File

@ -579,7 +579,7 @@ static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint
/* Copy the just gotten string to another buffer to remove any formatting /* Copy the just gotten string to another buffer to remove any formatting
* from it such as big fonts, etc. */ * from it such as big fonts, etc. */
for (ptr = buffer, dest = buffer2; *ptr != '\0'; ptr++) { for (ptr = buffer, dest = buffer2; *ptr != '\0'; ptr++) {
if ((byte)*ptr == '\r') { if (*ptr == '\r') {
dest[0] = dest[1] = dest[2] = dest[3] = ' '; dest[0] = dest[1] = dest[2] = dest[3] = ' ';
dest += 4; dest += 4;
} else if ((byte)*ptr >= ' ' && ((byte)*ptr < 0x88 || (byte)*ptr >= 0x99)) { } else if ((byte)*ptr >= ' ' && ((byte)*ptr < 0x88 || (byte)*ptr >= 0x99)) {

View File

@ -180,10 +180,9 @@ void DrawPlayerFace(uint32 face, int color, int x, int y)
void InvalidatePlayerWindows(Player *p) void InvalidatePlayerWindows(Player *p)
{ {
uint pid = p->index; PlayerID pid = p->index;
if ( (byte)pid == _local_player)
InvalidateWindow(WC_STATUS_BAR, 0);
if (pid == _local_player) InvalidateWindow(WC_STATUS_BAR, 0);
InvalidateWindow(WC_FINANCES, pid); InvalidateWindow(WC_FINANCES, pid);
} }

View File

@ -449,10 +449,10 @@ static void UpdateRoadVehDeltaXY(Vehicle *v)
}; };
#undef MKIT #undef MKIT
uint32 x = _delta_xy_table[v->direction]; uint32 x = _delta_xy_table[v->direction];
v->x_offs = (byte)x; v->x_offs = GB(x, 0, 8);
v->y_offs = (byte)(x>>=8); v->y_offs = GB(x, 8, 8);
v->sprite_width = (byte)(x>>=8); v->sprite_width = GB(x, 16, 8);
v->sprite_height = (byte)(x>>=8); v->sprite_height = GB(x, 24, 8);
} }
static void ClearCrashedStation(Vehicle *v) static void ClearCrashedStation(Vehicle *v)
@ -927,7 +927,7 @@ static void RoadVehCheckOvertake(Vehicle *v, Vehicle *u)
if (v->u.road.state >= 32 || (v->u.road.state&7) > 1 ) if (v->u.road.state >= 32 || (v->u.road.state&7) > 1 )
return; return;
tt = (byte)(GetTileTrackStatus(v->tile, TRANSPORT_ROAD) & 0x3F); tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD) & 0x3F;
if ((tt & 3) == 0) if ((tt & 3) == 0)
return; return;
if ((tt & 0x3C) != 0) if ((tt & 0x3C) != 0)

View File

@ -123,14 +123,14 @@ static inline uint64 SlReadUint64(void)
static inline void SlWriteUint16(uint16 v) static inline void SlWriteUint16(uint16 v)
{ {
SlWriteByte((byte)(v >> 8)); SlWriteByte(GB(v, 8, 8));
SlWriteByte((byte)v); SlWriteByte(GB(v, 0, 8));
} }
static inline void SlWriteUint32(uint32 v) static inline void SlWriteUint32(uint32 v)
{ {
SlWriteUint16((uint16)(v >> 16)); SlWriteUint16(GB(v, 16, 16));
SlWriteUint16((uint16)v); SlWriteUint16(GB(v, 0, 16));
} }
static inline void SlWriteUint64(uint64 x) static inline void SlWriteUint64(uint64 x)

View File

@ -312,10 +312,10 @@ static void UpdateShipDeltaXY(Vehicle *v, int dir)
}; };
#undef MKIT #undef MKIT
uint32 x = _delta_xy_table[dir]; uint32 x = _delta_xy_table[dir];
v->x_offs = (byte)x; v->x_offs = GB(x, 0, 8);
v->y_offs = (byte)(x>>=8); v->y_offs = GB(x, 8, 8);
v->sprite_width = (byte)(x>>=8); v->sprite_width = GB(x, 16, 8);
v->sprite_height = (byte)(x>>=8); v->sprite_height = GB(x, 24, 8);
} }
static void RecalcShipStuff(Vehicle *v) static void RecalcShipStuff(Vehicle *v)
@ -532,7 +532,7 @@ static uint FindShipTrack(Vehicle *v, TileIndex tile, int dir, uint bits, TileIn
/* if we reach this position, there's two paths of equal value so far. /* if we reach this position, there's two paths of equal value so far.
* pick one randomly. */ * pick one randomly. */
r = (byte)Random(); r = GB(Random(), 0, 8);
if (_pick_shiptrack_table[i] == ship_dir) r += 80; if (_pick_shiptrack_table[i] == ship_dir) r += 80;
if (_pick_shiptrack_table[best_track] == ship_dir) r -= 80; if (_pick_shiptrack_table[best_track] == ship_dir) r -= 80;
if (r <= 127) goto bad; if (r <= 127) goto bad;

View File

@ -893,12 +893,12 @@ static char *GenPresidentName(char *buff, uint32 x)
{ {
uint i, base, num; uint i, base, num;
buff[0] = _initial_name_letters[(sizeof(_initial_name_letters) * (byte)x) >> 8]; buff[0] = _initial_name_letters[sizeof(_initial_name_letters) * GB(x, 0, 8) >> 8];
buff[1] = '.'; buff[1] = '.';
buff[2] = ' '; // Insert a space after initial and period "I. Firstname" instead of "I.Firstname" buff[2] = ' '; // Insert a space after initial and period "I. Firstname" instead of "I.Firstname"
buff += 3; buff += 3;
i = ((sizeof(_initial_name_letters) + 35) * (byte)(x >> 8)) >> 8; i = (sizeof(_initial_name_letters) + 35) * GB(x, 8, 8) >> 8;
if (i < sizeof(_initial_name_letters)) { if (i < sizeof(_initial_name_letters)) {
buff[0] = _initial_name_letters[i]; buff[0] = _initial_name_letters[i];
buff[1] = '.'; buff[1] = '.';

View File

@ -92,7 +92,7 @@ static void DrawTile_Town(TileInfo *ti)
/* Retrieve pointer to the draw town tile struct */ /* Retrieve pointer to the draw town tile struct */
{ {
/* this "randomizes" on the (up to) 4 variants of a building */ /* this "randomizes" on the (up to) 4 variants of a building */
byte gfx = (byte)_m[ti->tile].m4; byte gfx = _m[ti->tile].m4;
byte stage = _m[ti->tile].m3 >> 6; byte stage = _m[ti->tile].m3 >> 6;
uint variant; uint variant;
variant = ti->x >> 4; variant = ti->x >> 4;
@ -304,16 +304,20 @@ static void TileLoop_Town(TileIndex tile)
r = Random(); r = Random();
if ( (byte)r < _housetype_population[house] ) { if (GB(r, 0, 8) < _housetype_population[house]) {
uint amt = ((byte)r >> 3) + 1, moved; uint amt = GB(r, 0, 8) / 8 + 1;
uint moved;
if (_economy.fluct <= 0) amt = (amt + 1) >> 1; if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
t->new_max_pass += amt; t->new_max_pass += amt;
moved = MoveGoodsToStation(tile, 1, 1, CT_PASSENGERS, amt); moved = MoveGoodsToStation(tile, 1, 1, CT_PASSENGERS, amt);
t->new_act_pass += moved; t->new_act_pass += moved;
} }
if ( (byte)(r>>8) < _housetype_mailamount[house] ) { if (GB(r, 8, 8) < _housetype_mailamount[house] ) {
uint amt = ((byte)(r>>8) >> 3) + 1, moved; uint amt = GB(r, 8, 8) / 8 + 1;
uint moved;
if (_economy.fluct <= 0) amt = (amt + 1) >> 1; if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
t->new_max_mail += amt; t->new_max_mail += amt;
moved = MoveGoodsToStation(tile, 1, 1, CT_MAIL, amt); moved = MoveGoodsToStation(tile, 1, 1, CT_MAIL, amt);
@ -321,17 +325,14 @@ static void TileLoop_Town(TileIndex tile)
} }
if (_house_more_flags[house]&8 && (t->flags12&1) && --t->time_until_rebuild == 0) { if (_house_more_flags[house]&8 && (t->flags12&1) && --t->time_until_rebuild == 0) {
r>>=16; t->time_until_rebuild = GB(r, 16, 6) + 130;
t->time_until_rebuild = (r & 63) + 130;
_current_player = OWNER_TOWN; _current_player = OWNER_TOWN;
ClearTownHouse(t, tile); ClearTownHouse(t, tile);
// rebuild with another house? // rebuild with another house?
if ( (byte) (r >> 8) >= 12) { if (GB(r, 24, 8) >= 12) DoBuildTownHouse(t, tile);
DoBuildTownHouse(t, tile);
}
_current_player = OWNER_NONE; _current_player = OWNER_NONE;
} }
@ -1303,7 +1304,7 @@ static void DoBuildTownHouse(Town *t, TileIndex tile)
// Value for map3lo // Value for map3lo
m3lo = 0xC0; m3lo = 0xC0;
if ((byte)r >= 220) m3lo &= (r>>8); if (GB(r, 0, 8) >= 220) m3lo &= (r>>8);
if (m3lo == 0xC0) if (m3lo == 0xC0)
ChangePopulation(t, _housetype_population[house]); ChangePopulation(t, _housetype_population[house]);

View File

@ -398,7 +398,6 @@ static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
int32 value; int32 value;
Vehicle *v; Vehicle *v;
const RailVehicleInfo *rvi; const RailVehicleInfo *rvi;
int dir;
const Engine *e; const Engine *e;
int x,y; int x,y;
@ -417,6 +416,7 @@ static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
byte img = rvi->image_index; byte img = rvi->image_index;
Vehicle *u, *w; Vehicle *u, *w;
uint dir;
v->spritenum = img; v->spritenum = img;
@ -432,9 +432,9 @@ static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
v->engine_type = engine; v->engine_type = engine;
dir = _m[tile].m5 & 3; dir = GB(_m[tile].m5, 0, 2);
v->direction = (byte)(dir*2+1); v->direction = dir * 2 + 1;
v->tile = tile; v->tile = tile;
x = TileX(tile) * TILE_SIZE | _vehicle_initial_x_fract[dir]; x = TileX(tile) * TILE_SIZE | _vehicle_initial_x_fract[dir];
@ -570,7 +570,7 @@ void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building)
int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{ {
const RailVehicleInfo *rvi; const RailVehicleInfo *rvi;
int value,dir; int value;
Vehicle *v, *u; Vehicle *v, *u;
UnitID unit_num; UnitID unit_num;
Engine *e; Engine *e;
@ -606,11 +606,13 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
uint dir;
v->unitnumber = unit_num; v->unitnumber = unit_num;
dir = _m[tile].m5 & 3; dir = GB(_m[tile].m5, 0, 2);
v->direction = (byte)(dir*2+1); v->direction = dir * 2 + 1;
v->tile = tile; v->tile = tile;
v->owner = _current_player; v->owner = _current_player;
v->x_pos = (x |= _vehicle_initial_x_fract[dir]); v->x_pos = (x |= _vehicle_initial_x_fract[dir]);
@ -1126,10 +1128,10 @@ static void UpdateTrainDeltaXY(Vehicle *v, int direction)
uint32 x = _delta_xy_table[direction]; uint32 x = _delta_xy_table[direction];
v->x_offs = (byte)x; v->x_offs = GB(x, 0, 8);
v->y_offs = (byte)(x>>=8); v->y_offs = GB(x, 8, 8);
v->sprite_width = (byte)(x>>=8); v->sprite_width = GB(x, 16, 8);
v->sprite_height = (byte)(x>>=8); v->sprite_height = GB(x, 24, 8);
} }
static void UpdateVarsAfterSwap(Vehicle *v) static void UpdateVarsAfterSwap(Vehicle *v)
@ -2116,7 +2118,7 @@ static bool CheckReverseTrain(Vehicle *v)
/* if we reach this position, there's two paths of equal value so far. /* if we reach this position, there's two paths of equal value so far.
* pick one randomly. */ * pick one randomly. */
r = (byte)Random(); r = GB(Random(), 0, 8);
if (_pick_track_table[i] == (v->direction & 3)) r += 80; if (_pick_track_table[i] == (v->direction & 3)) r += 80;
if (_pick_track_table[best_track] == (v->direction & 3)) r -= 80; if (_pick_track_table[best_track] == (v->direction & 3)) r -= 80;
if (r <= 127) goto bad; if (r <= 127) goto bad;
@ -3095,8 +3097,8 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
tile = v->tile; tile = v->tile;
// tunnel entrance? // tunnel entrance?
if (IsTunnelTile(tile) && (byte)((_m[tile].m5 & 3)*2+1) == v->direction) if (IsTunnelTile(tile) && GB(_m[tile].m5, 0, 2) * 2 + 1 == v->direction)
return true; return true;
// depot? // depot?
/* XXX -- When enabled, this makes it possible to crash trains of others /* XXX -- When enabled, this makes it possible to crash trains of others

View File

@ -377,8 +377,7 @@ not_valid_below:;
} }
_m[ti.tile].m2 = (bridge_type << 4) | m5; _m[ti.tile].m2 = (bridge_type << 4) | m5;
_m[ti.tile].m3 &= 0xF; SB(_m[ti.tile].m3, 4, 4, railtype);
_m[ti.tile].m3 |= (byte)(railtype << 4);
MarkTileDirtyByTile(ti.tile); MarkTileDirtyByTile(ti.tile);
} }
@ -549,8 +548,8 @@ int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (p1 != 0x200 && !ValParamRailtype(p1)) return CMD_ERROR; if (p1 != 0x200 && !ValParamRailtype(p1)) return CMD_ERROR;
_build_tunnel_railtype = (byte)(p1 & 0xFF); _build_tunnel_railtype = GB(p1, 0, 8);
_build_tunnel_bh = (byte)(p1 >> 8); _build_tunnel_bh = GB(p1, 8, 8);
_build_tunnel_endtile = 0; _build_tunnel_endtile = 0;
excavated_tile = 0; excavated_tile = 0;
@ -602,7 +601,7 @@ TileIndex CheckTunnelBusy(TileIndex tile, uint *length)
} while ( } while (
!IsTileType(tile, MP_TUNNELBRIDGE) || !IsTileType(tile, MP_TUNNELBRIDGE) ||
(_m[tile].m5 & 0xF0) != 0 || (_m[tile].m5 & 0xF0) != 0 ||
(byte)(_m[tile].m5 ^ 2) != m5 || (_m[tile].m5 ^ 2) != m5 ||
GetTileZ(tile) != z GetTileZ(tile) != z
); );
@ -1015,9 +1014,9 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
bool ice = _m[ti->tile].m4 & 0x80; bool ice = _m[ti->tile].m4 & 0x80;
// draw tunnel? // draw tunnel?
if ( (byte)(ti->map5&0xF0) == 0) { if ((ti->map5 & 0xF0) == 0) {
/* railway type */ /* railway type */
image = (_m[ti->tile].m3 & 0xF) * 8; image = GB(_m[ti->tile].m3, 0, 4) * 8;
/* ice? */ /* ice? */
if (ice) if (ice)

View File

@ -267,7 +267,7 @@ static void AnimateTile_Unmovable(TileIndex tile)
static void TileLoop_Unmovable(TileIndex tile) static void TileLoop_Unmovable(TileIndex tile)
{ {
byte m5 = _m[tile].m5; byte m5 = _m[tile].m5;
byte level; // HQ level (depends on company performance) in the range 1..5. uint level; // HQ level (depends on company performance) in the range 1..5.
uint32 r; uint32 r;
if (!(m5 & 0x80)) { if (!(m5 & 0x80)) {
@ -278,23 +278,22 @@ static void TileLoop_Unmovable(TileIndex tile)
/* HQ accepts passenger and mail; but we have to divide the values /* HQ accepts passenger and mail; but we have to divide the values
* between 4 tiles it occupies! */ * between 4 tiles it occupies! */
level = (m5 & ~0x80) / 4 + 1; level = GB(m5, 0, 7) / 4 + 1;
assert(level < 6); assert(level < 6);
r = Random(); r = Random();
// Top town buildings generate 250, so the top HQ type makes 256. // Top town buildings generate 250, so the top HQ type makes 256.
if ((byte) r < (256 / 4 / (6 - level))) { if (GB(r, 0, 8) < (256 / 4 / (6 - level))) {
uint amt = ((byte) r >> 3) / 4 + 1; uint amt = GB(r, 0, 8) / 8 / 4 + 1;
if (_economy.fluct <= 0) amt = (amt + 1) >> 1; if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
MoveGoodsToStation(tile, 2, 2, CT_PASSENGERS, amt); MoveGoodsToStation(tile, 2, 2, CT_PASSENGERS, amt);
} }
r >>= 8;
// Top town building generates 90, HQ can make up to 196. The // Top town building generates 90, HQ can make up to 196. The
// proportion passengers:mail is about the same as in the acceptance // proportion passengers:mail is about the same as in the acceptance
// equations. // equations.
if ((byte) r < (196 / 4 / (6 - level))) { if (GB(r, 8, 8) < (196 / 4 / (6 - level))) {
uint amt = ((byte) r >> 3) / 4 + 1; uint amt = GB(r, 8, 8) / 8 / 4 + 1;
if (_economy.fluct <= 0) amt = (amt + 1) >> 1; if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
MoveGoodsToStation(tile, 2, 2, CT_MAIL, amt); MoveGoodsToStation(tile, 2, 2, CT_MAIL, amt);
} }