Changeset - r2140:efb49af98a17
[Not reviewed]
master
0 23 0
tron - 19 years ago 2005-07-20 15:29:28
tron@openttd.org
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
23 files changed with 130 insertions and 128 deletions:
0 comments (0 inline, 0 general)
ai_old.c
Show inline comments
 
@@ -1531,21 +1531,22 @@ static void AiStateWantNewRoute(Player *
 
	}
 
}
 

	
 
static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo)
 
{
 
	uint values[NUM_CARGO];
 
	int w,h;
 
	int rad;
 

	
 
	for(;p->mode != 4;p++) if (p->mode == 1) {
 
		TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 

	
 
		w = ((p->attr>>1) & 7);
 
		h = ((p->attr>>4) & 7);
 
		if (p->attr&1) intswap(w, h);
 
		uint w;
 
		uint h;
 

	
 
		w = GB(p->attr, 1, 3);
 
		h = GB(p->attr, 4, 3);
 
		if (p->attr & 1) uintswap(w, h);
 

	
 

	
 
		if (_patches.modified_catchment) {
 
			rad = CA_TRAIN;
 
		} else {
 
			rad = 4;
aircraft_cmd.c
Show inline comments
 
@@ -1042,19 +1042,19 @@ static void HandleCrashedAircraft(Vehicl
 
			v->z_pos++;
 
		}
 
	}
 

	
 
	if (v->u.air.crashed_counter < 650) {
 
		if (CHANCE16R(1,32,r)) {
 
			v->direction = (v->direction+_crashed_aircraft_moddir[(r >> 16)&3]) & 7;
 
			v->direction = (v->direction + _crashed_aircraft_moddir[GB(r, 16, 2)]) & 7;
 
			SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
 
			r = Random();
 
			CreateEffectVehicleRel(v,
 
				4 + (r&0xF),
 
				4 + ((r>>4)&0xF),
 
				((r>>8)&0xF),
 
				GB(r, 0, 4) + 4,
 
				GB(r, 4, 4) + 4,
 
				GB(r, 8, 4),
 
				EV_EXPLOSION_SMALL);
 
		}
 
	} else if (v->u.air.crashed_counter >= 10000) {
 
		// remove rubble of crashed airplane
 

	
 
		// clear runway-in on all airports, set by crashing plane
clear_cmd.c
Show inline comments
 
@@ -467,13 +467,13 @@ void DrawClearLandTile(TileInfo *ti, byt
 

	
 
void DrawHillyLandTile(TileInfo *ti)
 
{
 
	if (ti->tileh != 0) {
 
		DrawGroundSprite(0xFA0 + _tileh_to_sprite[ti->tileh]);
 
	} else {
 
		DrawGroundSprite(_landscape_clear_sprites[((ti->x^ti->y) >> 4) & 0x7]);
 
		DrawGroundSprite(_landscape_clear_sprites[GB(ti->x ^ ti->y, 4, 3)]);
 
	}
 
}
 

	
 
void DrawClearLandFence(TileInfo *ti, byte img)
 
{
 
	byte z = ti->z;
 
@@ -482,17 +482,17 @@ void DrawClearLandFence(TileInfo *ti, by
 
		z += 8;
 
		if (ti->tileh == 0x17)
 
			z += 8;
 
	}
 

	
 
	if (img & 0x38) {
 
		DrawGroundSpriteAt(_clear_land_fence_sprites_1[((img >> 3) & 7) - 1] + _fence_mod_by_tileh[ti->tileh], ti->x, ti->y, z);
 
		DrawGroundSpriteAt(_clear_land_fence_sprites_1[GB(img, 3, 3) - 1] + _fence_mod_by_tileh[ti->tileh], ti->x, ti->y, z);
 
	}
 

	
 
	if (img & 0x7) {
 
		DrawGroundSpriteAt(_clear_land_fence_sprites_1[(img & 7) - 1] + _fence_mod_by_tileh_2[ti->tileh], ti->x, ti->y, z);
 
		DrawGroundSpriteAt(_clear_land_fence_sprites_1[GB(img, 0, 3) - 1] + _fence_mod_by_tileh_2[ti->tileh], ti->x, ti->y, z);
 
	}
 
}
 

	
 
static void DrawTile_Clear(TileInfo *ti)
 
{
 

	
 
@@ -782,13 +782,13 @@ void GenerateClearTile(void)
 
	/* add grey squares */
 
	i = ScaleByMapSize((Random() & 0x7F) + 0x80);
 
	do {
 
		r = Random();
 
		tile = RandomTileSeed(r);
 
		if (IsTileType(tile, MP_CLEAR)) {
 
			j = ((r >> 16) & 0xF) + 5;
 
			j = GB(r, 16, 4) + 5;
 
			for(;;) {
 
				TileIndex tile_new;
 

	
 
				_m[tile].m5 = (byte)((_m[tile].m5 & ~(3<<2)) | (2<<2));
 
				do {
 
					if (--j == 0) goto get_out;
disaster_cmd.c
Show inline comments
 
@@ -223,15 +223,15 @@ static void DisasterTick_Zeppeliner(Vehi
 
		v->u.disaster.image_override = 0xF43;
 
	} else if (v->age <= 300) {
 
		if (!(v->tick_counter&7)) {
 
			uint32 r = Random();
 

	
 
			CreateEffectVehicleRel(v,
 
				-7 + (r&0xF),
 
				-7 + (r>>4&0xF),
 
				5 + (r>>8&0x7),
 
				GB(r, 0, 4) - 7,
 
				GB(r, 4, 4) - 7,
 
				GB(r, 8, 3) + 5,
 
				EV_EXPLOSION_SMALL);
 
		}
 
	} else if (v->age == 350) {
 
		v->current_order.station = 3;
 
		v->age = 0;
 
	}
 
@@ -361,15 +361,15 @@ static void DisasterTick_2(Vehicle *v)
 
			Industry *i = GetIndustry(v->dest_tile);
 
			int x = TileX(i->xy) * 16;
 
			int y = TileY(i->xy) * 16;
 
			uint32 r = Random();
 

	
 
			CreateEffectVehicleAbove(
 
				x + (r & 0x3F),
 
				y + (r >> 6 & 0x3F),
 
				(r >> 12 & 0xF),
 
				GB(r,  0, 6) + x,
 
				GB(r,  6, 6) + y,
 
				GB(r, 12, 4),
 
				EV_EXPLOSION_SMALL);
 

	
 
			if (++v->age >= 55)
 
				v->current_order.station = 3;
 
		}
 
	} else if (v->current_order.station == 1) {
 
@@ -432,15 +432,15 @@ static void DisasterTick_3(Vehicle *v)
 
			Industry *i = GetIndustry(v->dest_tile);
 
			int x = TileX(i->xy) * 16;
 
			int y = TileY(i->xy) * 16;
 
			uint32 r = Random();
 

	
 
			CreateEffectVehicleAbove(
 
				x + (r & 0x3F),
 
				y + (r >> 6 & 0x3F),
 
				(r >> 12 & 0xF),
 
				GB(r,  0, 6) + x,
 
				GB(r,  6, 6) + y,
 
				GB(r, 12, 4),
 
				EV_EXPLOSION_SMALL);
 

	
 
			if (++v->age >= 55)
 
				v->current_order.station = 3;
 
		}
 
	} else if (v->current_order.station == 1) {
 
@@ -617,14 +617,14 @@ static void DisasterTick_4b(Vehicle *v)
 

	
 
		DeleteDisasterVeh(u);
 

	
 
		for(i=0; i!=80; i++) {
 
			uint32 r = Random();
 
			CreateEffectVehicleAbove(
 
				v->x_pos-32+(r&0x3F),
 
				v->y_pos-32+(r>>5&0x3F),
 
				GB(r, 0, 6) + v->x_pos - 32,
 
				GB(r, 5, 6) + v->y_pos - 32,
 
				0,
 
				EV_EXPLOSION_SMALL);
 
		}
 

	
 
		BEGIN_TILE_LOOP(tile, 6, 6, v->tile - TileDiffXY(3, 3))
 
			tile = TILE_MASK(tile);
engine.c
Show inline comments
 
@@ -193,28 +193,28 @@ void StartupEngines(void)
 
		e->age = 0;
 
		e->railtype = ei->railtype_climates >> 4;
 
		e->flags = 0;
 
		e->player_avail = 0;
 

	
 
		r = Random();
 
		e->intro_date = (uint16)((r & 0x1FF) + ei->base_intro);
 
		e->intro_date = GB(r, 0, 9) + ei->base_intro;
 
		if (e->intro_date <= _date) {
 
			e->age = (_date - e->intro_date) >> 5;
 
			e->player_avail = (byte)-1;
 
			e->flags |= ENGINE_AVAILABLE;
 
		}
 

	
 
		e->reliability_start = (uint16)(((r >> 16) & 0x3fff) + 0x7AE0);
 
		e->reliability_start = GB(r, 16, 14) + 0x7AE0;
 
		r = Random();
 
		e->reliability_max = (uint16)((r & 0x3fff) + 0xbfff);
 
		e->reliability_final = (uint16)(((r>>16) & 0x3fff) + 0x3fff);
 
		e->reliability_max   = GB(r,  0, 14) + 0xBFFF;
 
		e->reliability_final = GB(r, 16, 14) + 0x3FFF;
 

	
 
		r = Random();
 
		e->duration_phase_1 = (uint16)((r & 0x1F) + 7);
 
		e->duration_phase_2 = (uint16)(((r >> 5) & 0xF) + ei->base_life * 12 - 96);
 
		e->duration_phase_3 = (uint16)(((r >> 9) & 0x7F) + 120);
 
		e->duration_phase_1 = GB(r, 0, 5) + 7;
 
		e->duration_phase_2 = GB(r, 5, 4) + ei->base_life * 12 - 96;
 
		e->duration_phase_3 = GB(r, 9, 7) + 120;
 

	
 
		e->reliability_spd_dec = (ei->unk2&0x7F) << 2;
 

	
 
		/* my invented flag for something that is a wagon */
 
		if (ei->unk2 & 0x80) {
 
			e->age = 0xFFFF;
industry_cmd.c
Show inline comments
 
@@ -312,13 +312,13 @@ static void IndustryDrawTileProc4(TileIn
 
}
 

	
 
static void DrawCoalPlantSparkles(TileInfo *ti)
 
{
 
	int image = _m[ti->tile].owner;
 
	if (image & 0x80) {
 
		image = (image >> 2) & 0x1F;
 
		image = GB(image, 2, 5);
 
		if (image != 0 && image < 7) {
 
			AddChildSpriteScreen(image + 0x806,
 
				_coal_plant_sparkles_x[image-1],
 
				_coal_plant_sparkles_y[image-1]
 
			);
 
		}
 
@@ -1799,13 +1799,13 @@ static const byte _new_industry_rand[4][
 
static void MaybeNewIndustry(uint32 r)
 
{
 
	int type;
 
	int j;
 
	Industry *i;
 

	
 
	type = _new_industry_rand[_opt.landscape][(r >> 16) & 0x1F];
 
	type = _new_industry_rand[_opt.landscape][GB(r, 16, 5)];
 
	if (type == IT_OIL_WELL && _date > 10958)
 
		return;
 

	
 
	if (type == IT_OIL_RIG && _date < 14610)
 
		return;
 

	
landscape.c
Show inline comments
 
@@ -349,13 +349,13 @@ void CDECL ModifyTile(TileIndex tile, ui
 
{
 
	va_list va;
 
	int i;
 

	
 
	va_start(va, flags);
 

	
 
	if ((i = (flags >> 8) & 0xF) != 0) {
 
	if ((i = GB(flags, 8, 4)) != 0) {
 
		SetTileType(tile, i - 1);
 
	}
 

	
 
	if (flags & (MP_MAP2_CLEAR | MP_MAP2)) {
 
		int x = 0;
 
		if (flags & MP_MAP2) x = va_arg(va, int);
 
@@ -482,13 +482,13 @@ static void GenerateTerrain(int type, in
 
	y = (r >> MapLogX()) & MapMaxY();
 

	
 

	
 
	if (x < 2 || y < 2)
 
		return;
 

	
 
	direction = (r >> 22) & 3;
 
	direction = GB(r, 22, 2);
 
	if (direction & 1) {
 
		w = template->height;
 
		h = template->width;
 
	} else {
 
		w = template->width;
 
		h = template->height;
 
@@ -629,22 +629,22 @@ void GenerateLandscape(void)
 

	
 
	if (_opt.landscape == LT_HILLY) {
 
		for (i = ScaleByMapSize((Random() & 0x7F) + 950); i != 0; --i)
 
			GenerateTerrain(2, 0);
 

	
 
		r = Random();
 
		flag = (r & 3) | 4;
 
		for (i = ScaleByMapSize(((r >> 16) & 0x7F) + 450); i != 0; --i)
 
		flag = GB(r, 0, 2) | 4;
 
		for (i = ScaleByMapSize(GB(r, 16, 7) + 450); i != 0; --i)
 
			GenerateTerrain(4, flag);
 
	} else if (_opt.landscape == LT_DESERT) {
 
		for (i = ScaleByMapSize((Random()&0x7F) + 170); i != 0; --i)
 
			GenerateTerrain(0, 0);
 

	
 
		r = Random();
 
		flag = (r & 3) | 4;
 
		for (i = ScaleByMapSize(((r >> 16) & 0xFF) + 1700); i != 0; --i)
 
		flag = GB(r, 0, 2) | 4;
 
		for (i = ScaleByMapSize(GB(r, 16, 8) + 1700); i != 0; --i)
 
			GenerateTerrain(0, flag);
 

	
 
		flag ^= 2;
 

	
 
		for (i = ScaleByMapSize((Random() & 0x7F) + 410); i != 0; --i)
 
			GenerateTerrain(3, flag);
music_gui.c
Show inline comments
 
@@ -129,14 +129,14 @@ static void SelectSongToPlay(void)
 
	memset(_cur_playlist + i, 0, 33 - i);
 

	
 
	if (msf.shuffle) {
 
		i = 500;
 
		do {
 
			uint32 r = InteractiveRandom();
 
			byte *a = &_cur_playlist[r & 0x1F];
 
			byte *b = &_cur_playlist[(r >> 8)&0x1F];
 
			byte *a = &_cur_playlist[GB(r, 0, 5)];
 
			byte *b = &_cur_playlist[GB(r, 8, 5)];
 

	
 
			if (*a != 0 && *b != 0) {
 
				byte t = *a;
 
				*a = *b;
 
				*b = t;
 
			}
network_data.c
Show inline comments
 
@@ -41,36 +41,36 @@ void NetworkSend_uint8(Packet *packet, u
 
	packet->buffer[packet->size++] = data & 0xFF;
 
}
 

	
 
void NetworkSend_uint16(Packet *packet, uint16 data)
 
{
 
	assert(packet->size < sizeof(packet->buffer) - sizeof(data));
 
	packet->buffer[packet->size++] = data & 0xFF;
 
	packet->buffer[packet->size++] = (data >> 8) & 0xFF;
 
	packet->buffer[packet->size++] = GB(data, 0, 8);
 
	packet->buffer[packet->size++] = GB(data, 8, 8);
 
}
 

	
 
void NetworkSend_uint32(Packet *packet, uint32 data)
 
{
 
	assert(packet->size < sizeof(packet->buffer) - sizeof(data));
 
	packet->buffer[packet->size++] = data & 0xFF;
 
	packet->buffer[packet->size++] = (data >>= 8) & 0xFF;
 
	packet->buffer[packet->size++] = (data >>= 8) & 0xFF;
 
	packet->buffer[packet->size++] = (data >> 8) & 0xFF;
 
	packet->buffer[packet->size++] = GB(data,  0, 8);
 
	packet->buffer[packet->size++] = GB(data,  8, 8);
 
	packet->buffer[packet->size++] = GB(data, 16, 8);
 
	packet->buffer[packet->size++] = GB(data, 24, 8);
 
}
 

	
 
void NetworkSend_uint64(Packet *packet, uint64 data)
 
{
 
	assert(packet->size < sizeof(packet->buffer) - sizeof(data));
 
	packet->buffer[packet->size++] = data & 0xFF;
 
	packet->buffer[packet->size++] = (data >>= 8) & 0xFF;
 
	packet->buffer[packet->size++] = (data >>= 8) & 0xFF;
 
	packet->buffer[packet->size++] = (data >>= 8) & 0xFF;
 
	packet->buffer[packet->size++] = (data >>= 8) & 0xFF;
 
	packet->buffer[packet->size++] = (data >>= 8) & 0xFF;
 
	packet->buffer[packet->size++] = (data >>= 8) & 0xFF;
 
	packet->buffer[packet->size++] = (data >> 8) & 0xFF;
 
	packet->buffer[packet->size++] = GB(data,  0, 8);
 
	packet->buffer[packet->size++] = GB(data,  8, 8);
 
	packet->buffer[packet->size++] = GB(data, 16, 8);
 
	packet->buffer[packet->size++] = GB(data, 24, 8);
 
	packet->buffer[packet->size++] = GB(data, 32, 8);
 
	packet->buffer[packet->size++] = GB(data, 40, 8);
 
	packet->buffer[packet->size++] = GB(data, 48, 8);
 
	packet->buffer[packet->size++] = GB(data, 56, 8);
 
}
 

	
 
// Sends a string over the network. It sends out
 
//  the string + '\0'. No size-byte or something.
 
void NetworkSend_string(Packet *packet, const char* data)
 
{
oldloader.c
Show inline comments
 
@@ -719,14 +719,14 @@ static bool LoadOldStation(LoadgameState
 
	if (!LoadChunk(ls, st, station_chunk))
 
		return false;
 

	
 
	if (st->xy != 0) {
 
		if (st->train_tile) {
 
			/* Calculate the trainst_w and trainst_h */
 
			int w = (_old_platforms >> 3) & 0x7;
 
			int h = (_old_platforms & 0x7);
 
			uint w = GB(_old_platforms, 3, 3);
 
			uint h = GB(_old_platforms, 0, 3);
 
			st->trainst_w = w;
 
			st->trainst_h = h;
 
		}
 

	
 
		st->town    = GetTown(REMAP_TOWN_IDX(_old_town_index));
 
		st->string_id = RemapOldStringID(_old_string_id);
order.h
Show inline comments
 
@@ -132,15 +132,15 @@ static inline uint32 PackOrder(const Ord
 
	return order->station << 16 | order->flags << 8 | order->type;
 
}
 

	
 
static inline Order UnpackOrder(uint32 packed)
 
{
 
	Order order;
 
	order.type    = (packed & 0x000000FF);
 
	order.flags   = (packed & 0x0000FF00) >> 8;
 
	order.station = (packed & 0xFFFF0000) >> 16;
 
	order.type    = GB(packed,  0,  8);
 
	order.flags   = GB(packed,  8,  8);
 
	order.station = GB(packed, 16, 16);
 
	order.next    = NULL;
 
	order.index   = 0; // avoid compiler warning
 
	return order;
 
}
 

	
 
/* Functions */
order_cmd.c
Show inline comments
 
@@ -37,15 +37,15 @@ MemoryPool _order_pool = { "Orders", ORD
 
 * Unpacks a order from savegames made with TTD(Patch)
 
 *
 
 */
 
Order UnpackOldOrder(uint16 packed)
 
{
 
	Order order;
 
	order.type    = (packed & 0x000F);
 
	order.flags   = (packed & 0x00F0) >> 4;
 
	order.station = (packed & 0xFF00) >> 8;
 
	order.type    = GB(packed, 0, 4);
 
	order.flags   = GB(packed, 4, 4);
 
	order.station = GB(packed, 8, 8);
 
	order.next    = NULL;
 

	
 
	// Sanity check
 
	// TTD stores invalid orders as OT_NOTHING with non-zero flags/station
 
	if (order.type == OT_NOTHING && (order.flags != 0 || order.station != 0)) {
 
		order.type = OT_DUMMY;
 
@@ -60,15 +60,15 @@ Order UnpackOldOrder(uint16 packed)
 
 * Unpacks a order from savegames with version 4 and lower
 
 *
 
 */
 
Order UnpackVersion4Order(uint16 packed)
 
{
 
	Order order;
 
	order.type    = (packed & 0x000F);
 
	order.flags   = (packed & 0x00F0) >> 4;
 
	order.station = (packed & 0xFF00) >> 8;
 
	order.type    = GB(packed, 0, 4);
 
	order.flags   = GB(packed, 4, 4);
 
	order.station = GB(packed, 8, 8);
 
	order.next    = NULL;
 
	order.index   = 0; // avoid compiler warning
 
	return order;
 
}
 

	
 
/**
 
@@ -141,23 +141,23 @@ void AssignOrder(Order *order, Order dat
 
	order->station = data.station;
 
}
 

	
 
/** Add an order to the orderlist of a vehicle.
 
 * @param x,y unused
 
 * @param p1 various bitstuffed elements
 
 * - p1 = (bit  0 - 15) - ID of the vehicle (p1 & 0xFFFF)
 
 * - p1 = (bit  0 - 15) - ID of the vehicle
 
 * - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given,
 
 *                        the order will be inserted before that one (p1 & 0xFFFF0000)>>16
 
 *                        only the first 8 bytes used currently (bit 16 - 23) (max 255)
 
 *                        the order will be inserted before that one
 
 *                        only the first 8 bits used currently (bit 16 - 23) (max 255)
 
 * @param p2 packed order to insert
 
 */
 
int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	VehicleID veh = p1 & 0xFFFF;
 
	OrderID sel_ord = p1 >> 16;
 
	VehicleID veh   = GB(p1,  0, 16);
 
	OrderID sel_ord = GB(p1, 16, 16);
 
	Order new_order = UnpackOrder(p2);
 

	
 
	if (!IsVehicleIndex(veh)) return CMD_ERROR;
 
	v = GetVehicle(veh);
 
	if (v->type == 0 || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -506,24 +506,24 @@ int32 CmdSkipOrder(int x, int y, uint32 
 
}
 

	
 

	
 
/** Modify an order in the orderlist of a vehicle.
 
 * @param x,y unused
 
 * @param p1 various bitstuffed elements
 
 * - p1 = (bit  0 - 15) - ID of the vehicle (p1 & 0xFFFF)
 
 * - p1 = (bit  0 - 15) - ID of the vehicle
 
 * - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given,
 
 *                        the order will be inserted before that one (p1 & 0xFFFF0000)>>16
 
 *                        only the first 8 bytes used currently (bit 16 - 23) (max 255)
 
 *                        the order will be inserted before that one
 
 *                        only the first 8 bits used currently (bit 16 - 23) (max 255)
 
 * @param p2 mode to change the order to (always set)
 
 */
 
int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	Order *order;
 
	OrderID sel_ord = p1 >> 16; // XXX - automatically truncated to 8 bits.
 
	VehicleID veh = p1 & 0xFFFF;
 
	OrderID sel_ord = GB(p1, 16, 16); // XXX - automatically truncated to 8 bits.
 
	VehicleID veh   = GB(p1,  0, 16);
 

	
 
	if (!IsVehicleIndex(veh)) return CMD_ERROR;
 
	if (p2 != OFB_FULL_LOAD && p2 != OFB_UNLOAD && p2 != OFB_NON_STOP && p2 != OFB_TRANSFER) return CMD_ERROR;
 

	
 
	v = GetVehicle(veh);
 
	if (v->type == 0 || !CheckOwnership(v->owner)) return CMD_ERROR;
 
@@ -580,14 +580,14 @@ int32 CmdModifyOrder(int x, int y, uint3
 
 * - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE)
 
 * @param p2 mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE
 
 */
 
int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *dst;
 
	VehicleID veh_src = (p1 >> 16) & 0xFFFF;
 
	VehicleID veh_dst = p1 & 0xFFFF;
 
	VehicleID veh_src = GB(p1, 16, 16);
 
	VehicleID veh_dst = GB(p1,  0, 16);
 

	
 
	if (!IsVehicleIndex(veh_dst)) return CMD_ERROR;
 

	
 
	dst = GetVehicle(veh_dst);
 

	
 
	if (dst->type == 0 || !CheckOwnership(dst->owner)) return CMD_ERROR;
players.c
Show inline comments
 
@@ -42,23 +42,23 @@ void DrawPlayerFace(uint32 face, int col
 
	/* draw the cheeks */
 
	DrawSprite(cheeks_table[flag&3], x, y);
 

	
 
	/* draw the chin */
 
	/* FIXME: real code uses -2 in zoomlevel 1 */
 
	{
 
		uint val = (face >> 4) & 3;
 
		uint val = GB(face, 4, 2);
 
		if (!(flag & 2)) {
 
			DrawSprite(0x327 + (flag&1?0:val), x, y);
 
		} else {
 
			DrawSprite((flag&1?0x3B1:0x391) + (val>>1), x, y);
 
		}
 
	}
 
	/* draw the eyes */
 
	{
 
		uint val1 = (face >> 6)&15;
 
		uint val2 = (face >> 20)&7;
 
		uint val1 = GB(face,  6, 4);
 
		uint val2 = GB(face, 20, 3);
 
		uint32 high = 0x314<<16;
 

	
 
		if (val2 >= 6) {
 
			high = 0x30F<<16;
 
			if (val2 != 6)
 
				high = 0x30D<<16;
 
@@ -78,13 +78,13 @@ void DrawPlayerFace(uint32 face, int col
 
			}
 
		}
 
	}
 

	
 
	/* draw the mouth */
 
	{
 
		uint val = (face >> 10) & 63;
 
		uint val = GB(face, 10, 6);
 
		uint val2;
 

	
 
		if (!(flag&1)) {
 
			val2 = ((val&0xF) * 15 >> 4);
 

	
 
			if (val2 < 3) {
 
@@ -124,13 +124,13 @@ void DrawPlayerFace(uint32 face, int col
 
		skip_mouth:;
 
	}
 

	
 

	
 
	/* draw the hair */
 
	{
 
		uint val = (face >> 16) & 15;
 
		uint val = GB(face, 16, 4);
 
		if (!(flag&2)) {
 
			if (!(flag&1)) {
 
				DrawSprite(0x382 + (val*9>>4), x, y);
 
			} else {
 
				DrawSprite(0x38B + (val*5>>4), x, y);
 
			}
 
@@ -142,13 +142,13 @@ void DrawPlayerFace(uint32 face, int col
 
			}
 
		}
 
	}
 

	
 
	/* draw the tie */
 
	{
 
		uint val = (face >> 20) & 0xFF;
 
		uint val = GB(face, 20, 8);
 

	
 
		if (!(flag&1)) {
 
			DrawSprite(0x36B + ((val&3)*3>>2), x, y);
 
			DrawSprite(0x36E + ((val>>2)&3), x, y);
 
			DrawSprite(0x372 + ((val>>4)*6>>4), x, y);
 
		} else {
 
@@ -161,13 +161,13 @@ void DrawPlayerFace(uint32 face, int col
 
			}
 
		}
 
	}
 

	
 
	/* draw the glasses */
 
	{
 
		uint val = (face >> 28) & 7;
 
		uint val = GB(face, 28, 3);
 

	
 
		if (!(flag&2)) {
 
			if (val<=1) {
 
				DrawSprite(0x347 + val, x, y);
 
			}
 
		} else {
 
@@ -368,13 +368,13 @@ static byte GeneratePlayerColor(void)
 
		colors[i] = i;
 

	
 
	// And randomize it
 
	n = 100;
 
	do {
 
		r = Random();
 
		COLOR_SWAP(r & 0xF, (r >> 4) & 0xF);
 
		COLOR_SWAP(GB(r, 0, 4), GB(r, 4, 4));
 
	} while (--n);
 

	
 
	// Bubble sort it according to the values in table 1
 
	i = 16;
 
	do {
 
		for(j=0; j!=15; j++) {
 
@@ -751,14 +751,14 @@ int32 CmdPlayerCtrl(int x, int y, uint32
 
			p->money64 = p->player_money = 100000000; // XXX - wtf?
 
			p->is_active = false;
 
		}
 
	} break;
 

	
 
	case 3: { /* Merge a company (#1) into another company (#2), elimination company #1 */
 
		PlayerID pid_old = p2 & 0xFFFF;
 
		PlayerID pid_new = (p2 >> 16) & 0xFFFF;
 
		PlayerID pid_old = GB(p2,  0, 16);
 
		PlayerID pid_new = GB(p2, 16, 16);
 

	
 
		if (pid_old >= MAX_PLAYERS || pid_new >= MAX_PLAYERS) return CMD_ERROR;
 

	
 
		if (!(flags & DC_EXEC)) return CMD_ERROR;
 

	
 
		ChangeOwnershipOfPlayerItems(pid_old, pid_new);
rail_cmd.c
Show inline comments
 
@@ -574,13 +574,13 @@ static int32 ValidateAutoDrag(Trackdir *
 
 * - p2 = (bit 7)   - 0 = build, 1 = remove tracks
 
 */
 
static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int ex, ey;
 
	int32 ret, total_cost = 0;
 
	Track track = (Track)((p2 >> 4) & 7);
 
	Track track = (Track)GB(p2, 4, 3);
 
	Trackdir trackdir;
 
	byte mode = HASBIT(p2, 7);
 

	
 
	if (!ValParamRailtype(p2 & 0x3) || !ValParamTrackOrientation(track)) return CMD_ERROR;
 
	if (p1 > MapSize()) return CMD_ERROR;
 
	trackdir = TrackToTrackdir(track);
 
@@ -842,13 +842,13 @@ static int32 CmdSignalTrackHelper(int x,
 
	int32 ret, total_cost, signal_ctr;
 
	byte signals;
 
	TileIndex tile = TileVirtXY(x, y);
 
	bool error = true;
 

	
 
	int mode = p2 & 0x1;
 
	Track track = (p2 >> 4) & 7;
 
	Track track = GB(p2, 4, 3);
 
	Trackdir trackdir = TrackToTrackdir(track);
 
	byte semaphores = (HASBIT(p2, 3)) ? 8 : 0;
 
	byte signal_density = (p2 >> 24);
 

	
 
	if (p1 > MapSize()) return CMD_ERROR;
 
	if (signal_density == 0 || signal_density > 20) return CMD_ERROR;
road_cmd.c
Show inline comments
 
@@ -786,13 +786,13 @@ static void DrawTile_Road(TileInfo *ti)
 
				image = _road_tile_sprites_1[ti->map5 & 0xF];
 
			}
 
		} else {
 
			image = _road_tile_sprites_1[ti->map5 & 0xF];
 
		}
 

	
 
		m2 = (_m[ti->tile].m4 & 0x70) >> 4;
 
		m2 = GB(_m[ti->tile].m4, 4, 3);
 

	
 
		if (m2 == 0) image |= 0x3178000;
 

	
 
		if (_m[ti->tile].m4 & 0x80) {
 
			image += 19;
 
		} else if (m2 > 1 && m2 != 6) {
 
@@ -832,13 +832,13 @@ static void DrawTile_Road(TileInfo *ti)
 
		if ( (ti->map5 & 4) != 0)
 
			image += 2;
 

	
 
		if ( _m[ti->tile].m4 & 0x80) {
 
			image += 8;
 
		} else {
 
			m2 = (_m[ti->tile].m4 & 0x70) >> 4;
 
			m2 = GB(_m[ti->tile].m4, 4, 3);
 
			if (m2 == 0) image |= 0x3178000;
 
			if (m2 > 1) image += 4;
 
		}
 

	
 
		DrawGroundSprite(image + (_m[ti->tile].m4 & 0xF) * 12);
 

	
 
@@ -1003,25 +1003,25 @@ static void TileLoop_Road(TileIndex tile
 
		}
 
	}
 

	
 
	if (_m[tile].m5 & 0xE0)
 
		return;
 

	
 
	if (((_m[tile].m4 & 0x70) >> 4) < 6) {
 
	if (GB(_m[tile].m4, 4, 3) < 6) {
 
		t = ClosestTownFromTile(tile, (uint)-1);
 

	
 
		grp = 0;
 
		if (t != NULL) {
 
			grp = GetTownRadiusGroup(t, tile);
 

	
 
			// Show an animation to indicate road work
 
			if (t->road_build_months != 0 &&
 
					!(DistanceManhattan(t->xy, tile) >= 8 && grp == 0) &&
 
					(_m[tile].m5==5 || _m[tile].m5==10)) {
 
				if (GetTileSlope(tile, NULL) == 0 && EnsureNoVehicle(tile) && CHANCE16(1,20)) {
 
					_m[tile].m4 |= ((((_m[tile].m4 & 0x70) >> 4 ) <=  2) ? 7 : 6) << 4;
 
					_m[tile].m4 |= (GB(_m[tile].m4, 4, 3) <=  2 ? 7 : 6) << 4;
 

	
 
					SndPlayTileFx(SND_21_JACKHAMMER, tile);
 
					CreateEffectVehicleAbove(
 
						TileX(tile) * 16 + 7,
 
						TileY(tile) * 16 + 7,
 
						0,
 
@@ -1031,13 +1031,13 @@ static void TileLoop_Road(TileIndex tile
 
				}
 
			}
 
		}
 

	
 
		{
 
			const byte *p = (_opt.landscape == LT_CANDY) ? _town_road_types_2[grp] : _town_road_types[grp];
 
			byte b = (_m[tile].m4 & 0x70) >> 4;
 
			byte b = GB(_m[tile].m4, 4, 3);
 

	
 
			if (b == p[0])
 
				return;
 

	
 
			if (b == p[1]) {
 
				b = p[0];
 
@@ -1059,13 +1059,13 @@ static void TileLoop_Road(TileIndex tile
 
		//lower 4 bits of map3_hi store the counter now
 
		if ((b & 0xF) != 0xF) {
 
			_m[tile].m4 = b + 1;
 
			return;
 
		}
 
		//roadworks finished
 
		_m[tile].m4 = ((((b& 0x70) >> 4)== 6) ? 1 : 2) << 4;
 
		_m[tile].m4 = (GB(b, 4, 3) == 6 ? 1 : 2) << 4;
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 
void ShowRoadDepotWindow(TileIndex tile);
 

	
 
@@ -1087,13 +1087,13 @@ static uint32 GetTileTrackStatus_Road(Ti
 
			return 0;
 
		return _m[tile].m5 & 8 ? 0x101 : 0x202;
 
	} else if  (mode == TRANSPORT_ROAD) {
 
		byte b = _m[tile].m5;
 
		if ((b & 0xF0) == 0) {
 
			/* Ordinary road */
 
			if (!_road_special_gettrackstatus && ((_m[tile].m4&0x70) >> 4) >= 6)
 
			if (!_road_special_gettrackstatus && GB(_m[tile].m4, 4, 3) >= 6)
 
				return 0;
 
			return _road_trackbits[b&0xF] * 0x101;
 
		} else if (IsLevelCrossing(tile)) {
 
			/* Crossing */
 
			uint32 r = 0x101;
 
			if (b&8) r <<= 1;
 
@@ -1122,13 +1122,13 @@ static const StringID _road_tile_strings
 
};
 

	
 
static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
 
{
 
	int i = (_m[tile].m5 >> 4);
 
	if (i == 0)
 
		i = ((_m[tile].m4 & 0x70) >> 4) + 3;
 
		i = GB(_m[tile].m4, 4, 3) + 3;
 
	td->str = _road_tile_strings[i - 1];
 
	td->owner = GetTileOwner(tile);
 
}
 

	
 
static const byte _roadveh_enter_depot_unk0[4] = {
 
	8, 9, 0, 1
settings_gui.c
Show inline comments
 
@@ -1016,22 +1016,22 @@ static void PatchesSelectionWndProc(Wind
 
		break;
 
	}
 
}
 

	
 
/** Network-safe changing of patch-settings.
 
 * @param p1 various bitstuffed elements
 
 * - p1 = (bit 0- 7) - the patches type (page) that is being changed (construction, network, ai) (p1 & 0xFF)
 
 * - p2 = (bit 8-15) - the actual patch (entry) being set inside the category ((p1>>8) & 0xFF)
 
 * - p1 = (bit 0- 7) - the patches type (page) that is being changed (construction, network, ai)
 
 * - p2 = (bit 8-15) - the actual patch (entry) being set inside the category
 
 * @param p2 the new value for the patch
 
 * @todo check that the new value is a valid one. Awful lot of work, but since only
 
 * the server is allowed to do this, we trust it on this one :)
 
 */
 
int32 CmdChangePatchSetting(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	byte pcat = p1 & 0xFF;
 
	byte pel = (p1 >> 8) & 0xFF;
 
	byte pcat = GB(p1, 0, 8);
 
	byte pel  = GB(p1, 8, 8);
 

	
 
	if (pcat >= lengthof(_patches_page)) return CMD_ERROR;
 
	if (pel >= _patches_page[pcat].num) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		const PatchEntry *pe = &_patches_page[pcat].entries[pel];
station_cmd.c
Show inline comments
 
@@ -930,14 +930,14 @@ static void GetStationLayout(byte *layou
 
}
 

	
 
/** Build railroad station
 
 * @param x,y starting position of station dragging/placement
 
 * @param p1 various bitstuffed elements
 
 * - p1 = (bit  0)    - orientation (p1 & 1)
 
 * - p1 = (bit  8-15) - number of tracks (p1 >> 8) & 0xFF)
 
 * - p1 = (bit 16-23) - platform length (p1 >> 16) & 0xFF)
 
 * - p1 = (bit  8-15) - number of tracks
 
 * - p1 = (bit 16-23) - platform length
 
 * @param p2 various bitstuffed elements
 
 * - p2 = (bit  0- 3) - railtype (p2 & 0xF)
 
 * - p2 = (bit  4)    - set for custom station (p2 & 0x10)
 
 * - p2 = (bit  8-..) - custom station id (p2 >> 8)
 
 */
 
int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
@@ -958,14 +958,14 @@ int32 CmdBuildRailroadStation(int x, int
 
	/* Does the authority allow this? */
 
	if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR;
 
	if (!ValParamRailtype(p2 & 0xF)) return CMD_ERROR;
 

	
 
	/* unpack parameters */
 
	direction = p1 & 1;
 
	numtracks = (p1 >> 8) & 0xFF;
 
	plat_len = (p1 >> 16) & 0xFF;
 
	numtracks = GB(p1,  8, 8);
 
	plat_len  = GB(p1, 16, 8);
 
	/* w = length, h = num_tracks */
 
	if (direction) {
 
		h_org = plat_len;
 
		w_org = numtracks;
 
	} else {
 
		w_org = plat_len;
strings.c
Show inline comments
 
@@ -176,14 +176,14 @@ static const char *GetStringPtr(StringID
 
// The highest 8 bits of string contain the "case index".
 
// These 8 bits will only be set when FormatString wants to print
 
// the string in a different case. No one else except FormatString
 
// should set those bits.
 
char *GetStringWithArgs(char *buffr, uint string, const int32 *argv)
 
{
 
	uint index = string & 0x7FF;
 
	uint tab = (string >> 11) & 0x1F;
 
	uint index = GB(string,  0, 11);
 
	uint tab   = GB(string, 11,  5);
 

	
 
	if (!(string & 0xFFFF)) {
 
		error("!invalid string id 0 in GetString");
 
	}
 

	
 
	switch (tab) {
town_cmd.c
Show inline comments
 
@@ -766,13 +766,14 @@ static int GrowTownAtRoad(Town *t, TileI
 
// Generate a random road block
 
// The probability of a straight road
 
// is somewhat higher than a curved.
 
static int GenRandomRoadBits(void)
 
{
 
	uint32 r = Random();
 
	int a = r&3, b = (r >> 8) & 3;
 
	uint a = GB(r, 0, 2);
 
	uint b = GB(r, 8, 2);
 
	if (a == b) b ^= 2;
 
	return (1<<a)+(1<<b);
 
}
 

	
 
// Grow the town
 
// Returns true if a house was built, or no if the build failed.
 
@@ -1304,13 +1305,13 @@ static void DoBuildTownHouse(Town *t, Ti
 
			if ((byte)r >= 220) m3lo &= (r>>8);
 

	
 
			if (m3lo == 0xC0)
 
				ChangePopulation(t, _housetype_population[house]);
 

	
 
			// Initial value for map5.
 
			m5 = (r >> 16) & 0x3F;
 
			m5 = GB(r, 16, 6);
 
		}
 

	
 
		assert(IsTileType(tile, MP_CLEAR));
 

	
 
		ModifyTile(tile,
 
			MP_SETTYPE(MP_HOUSE) | MP_MAP3HI | MP_MAP3LO | MP_MAP2 | MP_MAP5 | MP_MAPOWNER,
train_cmd.c
Show inline comments
 
@@ -3010,15 +3010,15 @@ static void HandleCrashedTrain(Vehicle *
 
		u = v;
 
		do {
 
			if (--index < 0) {
 
				r = Random();
 

	
 
				CreateEffectVehicleRel(u,
 
					2 + ((r>>8)&7),
 
					2 + ((r>>16)&7),
 
					5 + (r&7),
 
					GB(r,  8, 3) + 2,
 
					GB(r, 16, 3) + 2,
 
					GB(r,  0, 3) + 5,
 
					EV_EXPLOSION_SMALL);
 
				break;
 
			}
 
		} while ( (u=u->next) != NULL);
 
	}
 

	
tunnelbridge_cmd.c
Show inline comments
 
@@ -181,14 +181,14 @@ int32 CmdBuildBridge(int x, int y, uint3
 
	int32 cost, terraformcost, ret;
 
	bool allow_on_slopes;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
	/* unpack parameters */
 
	bridge_type = p2 & 0xFF;
 
	railtype = (byte)(p2 >> 8);
 
	bridge_type = GB(p2, 0, 8);
 
	railtype    = GB(p2, 8, 8);
 

	
 
	if (p1 > MapSize()) return CMD_ERROR;
 

	
 
	// type of bridge
 
	if (HASBIT(railtype, 7)) { // bit 15 of original p2 param
 
		railtype = 0;
 
@@ -1020,14 +1020,14 @@ static void DrawTile_TunnelBridge(TileIn
 
		image = (_m[ti->tile].m3 & 0xF) * 8;
 

	
 
		/* ice? */
 
		if (ice)
 
			image += 32;
 

	
 
		image += _draw_tunnel_table_1[(ti->map5 >> 2) & 0x3];
 
		image += (ti->map5 & 3) << 1;
 
		image += _draw_tunnel_table_1[GB(ti->map5, 2, 2)];
 
		image += GB(ti->map5, 0, 2) * 2;
 
		DrawGroundSprite(image);
 

	
 
		AddSortableSpriteToDraw(image+1, ti->x + 15, ti->y + 15, 1, 1, 8, (byte)ti->z);
 
	// draw bridge?
 
	} else if ((byte)ti->map5 & 0x80) {
 
		// get type of track on the bridge.
 
@@ -1052,13 +1052,13 @@ static void DrawTile_TunnelBridge(TileIn
 

	
 
				// default sloped sprites..
 
				if (ti->tileh != 0) image = _track_sloped_sprites[ti->tileh - 1] + 0x3F3;
 
			}
 

	
 
			// bridge ending.
 
			b = _bridge_sprite_table[(_m[ti->tile].m2 >> 4) & 0xF][6];
 
			b = _bridge_sprite_table[GB(_m[ti->tile].m2, 4, 4)][6];
 
			b += (tmp&(3<<1))*4; /* actually ((tmp>>2)&3)*8 */
 
			b += (tmp&1); // direction
 
			if (ti->tileh == 0) b += 4; // sloped "entrance" ?
 
			if (ti->map5 & 0x20) b += 2; // which side
 

	
 
			image = *b;
 
@@ -1074,13 +1074,13 @@ static void DrawTile_TunnelBridge(TileIn
 
			AddSortableSpriteToDraw(image, ti->x, ti->y, 16, 16, 7, ti->z);
 
		} else {
 
			// bridge middle part.
 
			uint z;
 
			int x,y;
 

	
 
			image = (ti->map5 >> 3) & 3;	// type of stuff under bridge (only defined for 0,1)
 
			image = GB(ti->map5, 3, 2); // type of stuff under bridge (only defined for 0,1)
 
			assert(image <= 1);
 

	
 
			if (!(ti->map5 & 0x20)) {
 
				// draw land under bridge
 
				if (ice) image += 2;					// ice too?
 

	
 
@@ -1112,13 +1112,13 @@ static void DrawTile_TunnelBridge(TileIn
 
					if (ti->tileh != 0) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F;
 
					if (ice) image += 19; // ice?
 
				}
 
				DrawGroundSprite(image);
 
			}
 
			// get bridge sprites
 
			b = _bridge_sprite_table[(_m[ti->tile].m2 >> 4) & 0xF][_m[ti->tile].m2&0xF] + tmp * 4;
 
			b = _bridge_sprite_table[GB(_m[ti->tile].m2, 4, 4)][GB(_m[ti->tile].m2, 0, 4)] + tmp * 4;
 

	
 
			z = GetBridgeHeight(ti) + 5;
 

	
 
			// draw rail
 
			image = b[0];
 
			if (_display_opt & DO_TRANS_BUILDINGS) image = (image & 0x3FFF) | 0x03224000;
 
@@ -1282,15 +1282,15 @@ static const StringID _bridge_tile_str[(
 
	0,0,0,
 
};
 

	
 
static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td)
 
{
 
	if ((_m[tile].m5 & 0x80) == 0) {
 
		td->str = STR_5017_RAILROAD_TUNNEL + ((_m[tile].m5 >> 2) & 3);
 
		td->str = STR_5017_RAILROAD_TUNNEL + GB(_m[tile].m5, 2, 2);
 
	} else {
 
		td->str = _bridge_tile_str[ (_m[tile].m2 >> 4) + (((_m[tile].m5>>1)&3)<<4) ];
 
		td->str = _bridge_tile_str[GB(_m[tile].m5, 1, 2) << 4 | GB(_m[tile].m2, 4, 4)];
 

	
 
		/* scan to the end of the bridge, that's where the owner is stored */
 
		if (_m[tile].m5 & 0x40) {
 
			TileIndexDiff delta = _m[tile].m5 & 1 ? TileDiffXY(0, -1) : TileDiffXY(-1, 0);
 

	
 
			do tile += delta; while (_m[tile].m5 & 0x40);
vehicle.c
Show inline comments
 
@@ -609,14 +609,14 @@ void ViewportAddVehicles(DrawPixelInfo *
 
	}
 
}
 

	
 
static void ChimneySmokeInit(Vehicle *v)
 
{
 
	uint32 r = Random();
 
	v->cur_image = SPR_CHIMNEY_SMOKE_0 + (r & 7);
 
	v->progress = (r >> 16) & 7;
 
	v->cur_image = SPR_CHIMNEY_SMOKE_0 + GB(r, 0, 3);
 
	v->progress = GB(r, 16, 3);
 
}
 

	
 
static void ChimneySmokeTick(Vehicle *v)
 
{
 
	if (v->progress > 0) {
 
		v->progress--;
 
@@ -1296,14 +1296,14 @@ void CheckVehicleBreakdown(Vehicle *v)
 

	
 
	/* reduced breakdowns? */
 
	if (_opt.diff.vehicle_breakdowns == 1) rel += 0x6666;
 

	
 
	/* check if to break down */
 
	if (_breakdown_chance[(uint)min(rel, 0xffff) >> 10] <= v->breakdown_chance) {
 
		v->breakdown_ctr = (byte)(((r >> 16) & 0x3F) + 0x3F);
 
		v->breakdown_delay = (byte)(((r >> 24) & 0x7F) | 0x80);
 
		v->breakdown_ctr    = GB(r, 16, 6) + 0x3F;
 
		v->breakdown_delay  = GB(r, 24, 7) + 0x80;
 
		v->breakdown_chance = 0;
 
	}
 
}
 

	
 
static const StringID _vehicle_type_names[4] = {
 
	STR_019F_TRAIN,
win32.c
Show inline comments
 
@@ -2139,14 +2139,14 @@ int APIENTRY WinMain(HINSTANCE hInstance
 
	// CreateDirectory("autosave", NULL);
 

	
 
	// setup random seed to something quite random
 
#if defined(_MSC_VER)
 
	{
 
		uint64 seed = rdtsc();
 
		_random_seeds[0][0] = seed & 0xffffffff;
 
		_random_seeds[0][1] = seed >> 32;
 
		_random_seeds[0][0] = GB(seed,  0, 32);
 
		_random_seeds[0][1] = GB(seed, 32, 32);
 
	}
 
#else
 
	_random_seeds[0][0] = GetTickCount();
 
	_random_seeds[0][1] = _random_seeds[0][0] * 0x1234567;
 
#endif
 
	SeedMT(_random_seeds[0][0]);
0 comments (0 inline, 0 general)