Changeset - r3388:b8a9554bfe12
[Not reviewed]
master
0 2 0
celestar - 18 years ago 2006-03-31 09:09:26
celestar@openttd.org
(svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
2 files changed with 17 insertions and 13 deletions:
0 comments (0 inline, 0 general)
unmovable_cmd.c
Show inline comments
 
@@ -64,26 +64,19 @@ void UpdateCompanyHQ(Player *p, uint sco
 
	byte val;
 
	TileIndex tile = p->location_of_house;
 

	
 
	if (tile == 0)
 
		return;
 

	
 
	(val = 128, score < 170) ||
 
	(val+= 4, score < 350) ||
 
	(val+= 4, score < 520) ||
 
	(val+= 4, score < 720) ||
 
	(val+= 4, true);
 
	(val = 0, score < 170) ||
 
	(val++, score < 350) ||
 
	(val++, score < 520) ||
 
	(val++, score < 720) ||
 
	(val++, true);
 

	
 
/* house is already big enough */
 
	if (val <= _m[tile].m5)
 
		return;
 

	
 
	_m[tile + TileDiffXY(0, 0)].m5 =   val;
 
	_m[tile + TileDiffXY(0, 1)].m5 = ++val;
 
	_m[tile + TileDiffXY(1, 0)].m5 = ++val;
 
	_m[tile + TileDiffXY(1, 1)].m5 = ++val;
 
	EnlargeCompanyHQ(tile, val);
 

	
 
	MarkTileDirtyByTile(tile + TileDiffXY(0, 0));
 
	MarkTileDirtyByTile(tile + TileDiffXY(0, 1));
 
	MarkTileDirtyByTile(tile + TileDiffXY(1, 0));
 
	MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
 
}
unmovable_map.h
Show inline comments
 
@@ -36,12 +36,23 @@ static inline bool IsOwnedLand(TileIndex
 
static inline bool IsOwnedLandTile(TileIndex t)
 
{
 
	return IsTileType(t, MP_UNMOVABLE) && IsOwnedLand(t);
 
}
 

	
 

	
 
static inline void EnlargeCompanyHQ(TileIndex t, byte size)
 
{
 
	if (size <= _m[t].m5 - UNMOVABLE_HQ_NORTH) return;
 

	
 
	_m[t + TileDiffXY(0, 0)].m5 = UNMOVABLE_HQ_NORTH + size * 4;
 
	_m[t + TileDiffXY(0, 1)].m5 = UNMOVABLE_HQ_WEST  + size * 4;
 
	_m[t + TileDiffXY(1, 0)].m5 = UNMOVABLE_HQ_EAST  + size * 4;
 
	_m[t + TileDiffXY(1, 1)].m5 = UNMOVABLE_HQ_SOUTH + size * 4;
 
}
 

	
 

	
 
static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o)
 
{
 
	SetTileType(t, MP_UNMOVABLE);
 
	SetTileOwner(t, o);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
0 comments (0 inline, 0 general)