src/town_map.h
changeset 9006 7666e7b47088
parent 9005 d6b0e0a54ef2
child 9483 cdefc44b5f60
equal deleted inserted replaced
9005:d6b0e0a54ef2 9006:7666e7b47088
     4 
     4 
     5 #ifndef TOWN_MAP_H
     5 #ifndef TOWN_MAP_H
     6 #define TOWN_MAP_H
     6 #define TOWN_MAP_H
     7 
     7 
     8 #include "town.h"
     8 #include "town.h"
     9 #include "date_func.h"
     9 #include "date_type.h"
    10 #include "tile_map.h"
    10 #include "tile_map.h"
    11 #include "functions.h"
       
    12 #include "animated_tile_func.h"
       
    13 
    11 
    14 /**
    12 /**
    15  * Get the index of which town this house/street is attached to.
    13  * Get the index of which town this house/street is attached to.
    16  * @param t the tile
    14  * @param t the tile
    17  * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD)
    15  * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD)
   112  * @param t the tile
   110  * @param t the tile
   113  */
   111  */
   114 static inline void HaltLift(TileIndex t)
   112 static inline void HaltLift(TileIndex t)
   115 {
   113 {
   116 	SB(_me[t].m7, 0, 4, 0);
   114 	SB(_me[t].m7, 0, 4, 0);
   117 	DeleteAnimatedTile(t);
       
   118 }
   115 }
   119 
   116 
   120 /**
   117 /**
   121  * Get the position of the lift on this animated house
   118  * Get the position of the lift on this animated house
   122  * @param t the tile
   119  * @param t the tile
   205 	SetHouseType(t, type);
   202 	SetHouseType(t, type);
   206 	SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
   203 	SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
   207 	_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
   204 	_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
   208 	SetHouseAnimationFrame(t, 0);
   205 	SetHouseAnimationFrame(t, 0);
   209 	_me[t].m7 = GetHouseSpecs(type)->processing_time;
   206 	_me[t].m7 = GetHouseSpecs(type)->processing_time;
   210 
       
   211 	if (GetHouseSpecs(type)->building_flags & BUILDING_IS_ANIMATED) AddAnimatedTile(t);
       
   212 	MarkTileDirtyByTile(t);
       
   213 }
   207 }
   214 
   208 
   215 /**
   209 /**
   216  * House Construction Scheme.
   210  * House Construction Scheme.
   217  *  Construction counter, for buildings under construction. Incremented on every
   211  *  Construction counter, for buildings under construction. Incremented on every
   265 
   259 
   266 	if (GB(_m[t].m5, 3, 2) == TOWN_HOUSE_COMPLETED) {
   260 	if (GB(_m[t].m5, 3, 2) == TOWN_HOUSE_COMPLETED) {
   267 		/* House is now completed.
   261 		/* House is now completed.
   268 		 * Store the year of construction as well, for newgrf house purpose */
   262 		 * Store the year of construction as well, for newgrf house purpose */
   269 		SetHouseCompleted(t, true);
   263 		SetHouseCompleted(t, true);
   270 		_m[t].m5 = Clamp(_cur_year - ORIGINAL_BASE_YEAR, 0, 0xFF);
       
   271 	}
   264 	}
       
   265 }
       
   266 
       
   267 /**
       
   268  * Set the year that this house was constructed (between 1920 and 2175).
       
   269  * @param t the tile of this house
       
   270  * @param year the year to set
       
   271  * @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
       
   272  */
       
   273 static inline void SetHouseConstructionYear(TileIndex t, Year year)
       
   274 {
       
   275 	assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t));
       
   276 	_m[t].m5 = Clamp(year - ORIGINAL_BASE_YEAR, 0, 0xFF);
   272 }
   277 }
   273 
   278 
   274 /**
   279 /**
   275  * Get the year that this house was constructed (between 1920 and 2175).
   280  * Get the year that this house was constructed (between 1920 and 2175).
   276  * @param t the tile of this house
   281  * @param t the tile of this house