(svn r2886) Rename the "owner" attribute to "m1", because when it stores an owner it is accessed by [GS]etOwner anyway and when it doesn't store an owner, but arbitrary data, accessing a field called "owner" is confusing.

This commit is contained in:
tron 2005-08-23 18:47:04 +00:00
parent 9d9ee2fe56
commit b45aeb5c36
11 changed files with 51 additions and 51 deletions

View File

@ -337,7 +337,7 @@ static void DestructIndustry(Industry *i)
for (tile = 0; tile != MapSize(); tile++) {
if (IsTileType(tile, MP_INDUSTRY) && _m[tile].m2 == i->index) {
_m[tile].owner = 0;
_m[tile].m1 = 0;
MarkTileDirtyByTile(tile);
}
}

View File

@ -260,7 +260,7 @@ static void IndustryDrawTileProc1(TileInfo *ti)
const DrawIndustrySpec1Struct *d;
uint32 image;
if (!(_m[ti->tile].owner & 0x80))
if (!(_m[ti->tile].m1 & 0x80))
return;
d = &_draw_industry_spec1[_m[ti->tile].m3];
@ -279,7 +279,7 @@ static void IndustryDrawTileProc2(TileInfo *ti)
{
int x = 0;
if (_m[ti->tile].owner & 0x80) {
if (_m[ti->tile].m1 & 0x80) {
x = _industry_anim_offs[_m[ti->tile].m3];
if ( (byte)x == 0xFF)
x = 0;
@ -291,7 +291,7 @@ static void IndustryDrawTileProc2(TileInfo *ti)
static void IndustryDrawTileProc3(TileInfo *ti)
{
if (_m[ti->tile].owner & 0x80) {
if (_m[ti->tile].m1 & 0x80) {
AddChildSpriteScreen(0x128B, 5,
_industry_anim_offs_2[_m[ti->tile].m3]);
}
@ -318,7 +318,7 @@ static void IndustryDrawTileProc4(TileInfo *ti)
static void DrawCoalPlantSparkles(TileInfo *ti)
{
int image = _m[ti->tile].owner;
int image = _m[ti->tile].m1;
if (image & 0x80) {
image = GB(image, 2, 5);
if (image != 0 && image < 7) {
@ -351,7 +351,7 @@ static void DrawTile_Industry(TileInfo *ti)
ormod = (ind->color_map+0x307) << PALETTE_SPRITE_START;
/* Retrieve pointer to the draw industry tile struct */
dits = &_industry_draw_tile_data[(ti->map5<<2) | (_m[ti->tile].owner&3)];
dits = &_industry_draw_tile_data[(ti->map5 << 2) | (_m[ti->tile].m1 & 3)];
image = dits->sprite_1;
if (image & PALETTE_MODIFIER_COLOR && (image & PALETTE_SPRITE_MASK) == 0)
@ -427,7 +427,7 @@ static void GetTileDesc_Industry(TileIndex tile, TileDesc *td)
td->owner = i->owner;
td->str = STR_4802_COAL_MINE + i->type;
if ((_m[tile].owner & 0x80) == 0) {
if ((_m[tile].m1 & 0x80) == 0) {
SetDParamX(td->dparam, 0, td->str);
td->str = STR_2058_UNDER_CONSTRUCTION;
}
@ -486,8 +486,8 @@ static void TransportIndustryGoods(TileIndex tile)
am = MoveGoodsToStation(i->xy, i->width, i->height, i->produced_cargo[0], cw);
i->last_mo_transported[0] += am;
if (am != 0 && (m5 = _industry_produce_map5[_m[tile].m5]) != 0xFF) {
_m[tile].m1 = 0x80;
_m[tile].m5 = m5;
_m[tile].owner = 0x80;
MarkTileDirtyByTile(tile);
}
}
@ -566,12 +566,12 @@ static void AnimateTile_Industry(TileIndex tile)
// Sparks on a coal plant
case 10:
if ((_tick_counter & 3) == 0) {
m = _m[tile].owner;
m = _m[tile].m1;
if ((m & (31<<2)) == (6 << 2)) {
_m[tile].owner = m&~(31<<2);
_m[tile].m1 = m&~(31<<2);
DeleteAnimatedTile(tile);
} else {
_m[tile].owner = m + (1<<2);
_m[tile].m1 = m + (1<<2);
MarkTileDirtyByTile(tile);
}
}
@ -612,16 +612,16 @@ static void AnimateTile_Industry(TileIndex tile)
case 30: case 31: case 32:
if ((_tick_counter & 7) == 0) {
bool b = CHANCE16(1,7);
m = _m[tile].owner;
m = _m[tile].m1;
m = (m & 3) + 1;
n = _m[tile].m5;
if (m == 4 && (m=0,++n) == 32+1 && (n=30,b)) {
_m[tile].owner = 0x83;
_m[tile].m1 = 0x83;
_m[tile].m5 = 29;
DeleteAnimatedTile(tile);
} else {
_m[tile].m1 = (_m[tile].m1 & ~3) | m;
_m[tile].m5 = n;
_m[tile].owner = (_m[tile].owner & ~3) | m;
MarkTileDirtyByTile(tile);
}
}
@ -637,8 +637,8 @@ static void AnimateTile_Industry(TileIndex tile)
if (state < 0x1A0) {
if (state < 0x20 || state >= 0x180) {
if (! (_m[tile].owner & 0x40)) {
_m[tile].owner |= 0x40;
if (!(_m[tile].m1 & 0x40)) {
_m[tile].m1 |= 0x40;
SndPlayTileFx(SND_0B_MINING_MACHINERY, tile);
}
if (state & 7)
@ -647,9 +647,9 @@ static void AnimateTile_Industry(TileIndex tile)
if (state & 3)
return;
}
m = (_m[tile].owner + 1) | 0x40;
m = (_m[tile].m1 + 1) | 0x40;
if (m > 0xC2) m = 0xC0;
_m[tile].owner = m;
_m[tile].m1 = m;
MarkTileDirtyByTile(tile);
} else if (state >= 0x200 && state < 0x3A0) {
int i;
@ -657,9 +657,9 @@ static void AnimateTile_Industry(TileIndex tile)
if (state & i)
return;
m = (_m[tile].owner & 0xBF) - 1;
m = (_m[tile].m1 & 0xBF) - 1;
if (m < 0x80) m = 0x82;
_m[tile].owner = m;
_m[tile].m1 = m;
MarkTileDirtyByTile(tile);
}
} break;
@ -678,17 +678,17 @@ static void MakeIndustryTileBigger(TileIndex tile, byte size)
byte b = (byte)((size + (1<<2)) & (3<<2));
if (b != 0) {
_m[tile].owner = b | (size & 3);
_m[tile].m1 = b | (size & 3);
return;
}
size = (size + 1) & 3;
if (size == 3) size |= 0x80;
_m[tile].owner = size | b;
_m[tile].m1 = size | b;
MarkTileDirtyByTile(tile);
if (!(_m[tile].owner & 0x80))
if (!(_m[tile].m1 & 0x80))
return;
switch(_m[tile].m5) {
@ -745,8 +745,8 @@ static void TileLoop_Industry(TileIndex tile)
{
byte n;
if (!(_m[tile].owner & 0x80)) {
MakeIndustryTileBigger(tile, _m[tile].owner);
if (!(_m[tile].m1 & 0x80)) {
MakeIndustryTileBigger(tile, _m[tile].m1);
return;
}
@ -757,14 +757,14 @@ static void TileLoop_Industry(TileIndex tile)
n = _industry_map5_animation_next[_m[tile].m5];
if (n != 255) {
_m[tile].m1 = 0;
_m[tile].m5 = n;
_m[tile].owner = 0;
MarkTileDirtyByTile(tile);
return;
}
#define SET_AND_ANIMATE(tile,a,b) { _m[tile].m5=a; _m[tile].owner=b; AddAnimatedTile(tile); }
#define SET_AND_UNANIMATE(tile,a,b) { _m[tile].m5=a; _m[tile].owner=b; DeleteAnimatedTile(tile); }
#define SET_AND_ANIMATE(tile, a, b) { _m[tile].m5 = a; _m[tile].m1 = b; AddAnimatedTile(tile); }
#define SET_AND_UNANIMATE(tile, a, b) { _m[tile].m5 = a; _m[tile].m1 = b; DeleteAnimatedTile(tile); }
switch(_m[tile].m5) {
case 0x18: // coast line at oilrigs
@ -1032,7 +1032,7 @@ static void ChopLumberMillTrees(Industry *i)
TileIndex tile = i->xy;
int dir, a, j;
if ((_m[tile].owner & 0x80) == 0)
if ((_m[tile].m1 & 0x80) == 0)
return;
/* search outwards as a rectangular spiral */
@ -1525,7 +1525,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
SetTileType(cur_tile, MP_INDUSTRY);
_m[cur_tile].m5 = it->map5;
_m[cur_tile].m2 = i->index;
_m[cur_tile].owner = _generating_world ? 0x1E : 0; /* maturity */
_m[cur_tile].m1 = _generating_world ? 0x1E : 0; /* maturity */
}
} while ((++it)->ti.x != -0x80);

View File

@ -382,7 +382,7 @@ void CDECL ModifyTile(TileIndex tile, uint flags, ...)
if (flags & (MP_MAPOWNER|MP_MAPOWNER_CURRENT)) {
byte x = _current_player;
if (flags & MP_MAPOWNER) x = va_arg(va, int);
_m[tile].owner = x;
_m[tile].m1 = x;
}
if (flags & MP_MAP5) {
@ -436,7 +436,7 @@ void InitializeLandscape(void)
map_size = MapSize();
for (i = 0; i < map_size; i++) {
_m[i].type_height = MP_CLEAR << 4;
_m[i].owner = OWNER_NONE;
_m[i].m1 = OWNER_NONE;
_m[i].m2 = 0;
_m[i].m3 = 0;
_m[i].m4 = 0;

2
map.h
View File

@ -19,7 +19,7 @@ extern uint _map_size;
typedef struct Tile {
byte type_height;
byte owner;
byte m1;
uint16 m2;
byte m3;
byte m4;

10
misc.c
View File

@ -771,7 +771,7 @@ static void Save_MAPT(void)
}
}
static void Load_MAPO(void)
static void Load_MAP1(void)
{
uint size = MapSize();
uint i;
@ -781,11 +781,11 @@ static void Load_MAPO(void)
uint j;
SlArray(buf, lengthof(buf), SLE_UINT8);
for (j = 0; j != lengthof(buf); j++) _m[i++].owner = buf[j];
for (j = 0; j != lengthof(buf); j++) _m[i++].m1 = buf[j];
}
}
static void Save_MAPO(void)
static void Save_MAP1(void)
{
uint size = MapSize();
uint i;
@ -795,7 +795,7 @@ static void Save_MAPO(void)
byte buf[4096];
uint j;
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].owner;
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m1;
SlArray(buf, lengthof(buf), SLE_UINT8);
}
}
@ -988,7 +988,7 @@ static void Load_CHTS(void)
const ChunkHandler _misc_chunk_handlers[] = {
{ 'MAPS', Save_MAPS, Load_MAPS, CH_RIFF },
{ 'MAPT', Save_MAPT, Load_MAPT, CH_RIFF },
{ 'MAPO', Save_MAPO, Load_MAPO, CH_RIFF },
{ 'MAPO', Save_MAP1, Load_MAP1, CH_RIFF },
{ 'MAP2', Save_MAP2, Load_MAP2, CH_RIFF },
{ 'M3LO', Save_MAP3, Load_MAP3, CH_RIFF },
{ 'M3HI', Save_MAP4, Load_MAP4, CH_RIFF },

View File

@ -164,11 +164,11 @@ static void Place_LandInfo(TileIndex tile)
DEBUG(misc, 0) ("TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile));
DEBUG(misc, 0) ("TILE: %d ", tile);
DEBUG(misc, 0) ("_type_height = %#x", _m[tile].type_height);
DEBUG(misc, 0) ("m1 = %#x", _m[tile].m1);
DEBUG(misc, 0) ("m2 = %#x", _m[tile].m2);
DEBUG(misc, 0) ("m3 = %#x", _m[tile].m3);
DEBUG(misc, 0) ("m4 = %#x", _m[tile].m4);
DEBUG(misc, 0) ("m5 = %#x", _m[tile].m5);
DEBUG(misc, 0) ("owner = %#x", _m[tile].owner);
#endif
}

View File

@ -1400,7 +1400,7 @@ static bool LoadOldMapPart1(LoadgameState *ls, int num)
uint i;
for (i = 0; i < OLD_MAP_SIZE; i++) {
_m[i].owner = ReadByte(ls);
_m[i].m1 = ReadByte(ls);
}
for (i = 0; i < OLD_MAP_SIZE; i++) {
_m[i].m2 = ReadByte(ls);

View File

@ -1008,9 +1008,9 @@ static void ConvertTownOwner(void)
if (IsLevelCrossing(tile) && _m[tile].m3 & 0x80)
_m[tile].m3 = OWNER_TOWN;
if (_m[tile].owner & 0x80) SetTileOwner(tile, OWNER_TOWN);
if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN);
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
if (_m[tile].owner & 0x80) SetTileOwner(tile, OWNER_TOWN);
if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN);
}
}
}

4
tile.h
View File

@ -109,7 +109,7 @@ static inline Owner GetTileOwner(TileIndex tile)
assert(!IsTileType(tile, MP_VOID));
assert(!IsTileType(tile, MP_INDUSTRY));
return _m[tile].owner;
return _m[tile].m1;
}
static inline void SetTileOwner(TileIndex tile, Owner owner)
@ -119,7 +119,7 @@ static inline void SetTileOwner(TileIndex tile, Owner owner)
assert(!IsTileType(tile, MP_VOID));
assert(!IsTileType(tile, MP_INDUSTRY));
_m[tile].owner = owner;
_m[tile].m1 = owner;
}
static inline bool IsTileOwner(TileIndex tile, Owner owner)

View File

@ -78,7 +78,7 @@ typedef struct DrawTownTileStruct {
static void TownDrawHouseLift(TileInfo *ti)
{
AddChildSpriteScreen(0x5A3, 0xE, 0x3C - (_m[ti->tile].owner&0x7F));
AddChildSpriteScreen(0x5A3, 0xE, 0x3C - (_m[ti->tile].m1 & 0x7F));
}
typedef void TownDrawTileProc(TileInfo *ti);
@ -173,8 +173,8 @@ static void AnimateTile_Town(TileIndex tile)
return;
}
if (!((old=_m[tile].owner)&0x80)) {
_m[tile].owner |= 0x80;
if (!((old = _m[tile].m1) & 0x80)) {
_m[tile].m1 |= 0x80;
do {
i = (Random()&7) - 1;
@ -183,14 +183,14 @@ static void AnimateTile_Town(TileIndex tile)
SB(_m[tile].m5, 0, 6, i);
}
a = _m[tile].owner&0x7F;
a = _m[tile].m1 & 0x7F;
b = (_m[tile].m5&0x3F) * 6;
a += (a < b) ? 1 : -1;
_m[tile].owner = (_m[tile].owner&0x80)|a;
_m[tile].m1 = (_m[tile].m1 & 0x80) | a;
if (a == b) {
_m[tile].m1 &= 0x7F;
_m[tile].m5 &= 0x40;
_m[tile].owner &= 0x7F;
DeleteAnimatedTile(tile);
}

View File

@ -2458,7 +2458,7 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
break;
case MP_STREET:
// tracks over roads, do owner check of tracks (_m[tile].owner)
// tracks over roads, do owner check of tracks
return
IsTileOwner(tile, v->owner) &&
(v->subtype != TS_Front_Engine || (_m[tile].m4 & 0xF) == v->u.rail.railtype);