src/newgrf_house.cpp
changeset 7922 a7e266f966d9
parent 7868 0775357181e8
child 7928 63e18de69e50
equal deleted inserted replaced
7921:3437fdd5c0a8 7922:a7e266f966d9
   209 	switch (variable) {
   209 	switch (variable) {
   210 		/* Construction stage. */
   210 		/* Construction stage. */
   211 		case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | OriginalTileRandomiser(TileX(tile), TileY(tile)) << 2;
   211 		case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | OriginalTileRandomiser(TileX(tile), TileY(tile)) << 2;
   212 
   212 
   213 		/* Building age. */
   213 		/* Building age. */
   214 		case 0x41: return clamp(_cur_year - GetHouseConstructionYear(tile), 0, 0xFF);
   214 		case 0x41: return Clamp(_cur_year - GetHouseConstructionYear(tile), 0, 0xFF);
   215 
   215 
   216 		/* Town zone */
   216 		/* Town zone */
   217 		case 0x42: return GetTownRadiusGroup(town, tile);
   217 		case 0x42: return GetTownRadiusGroup(town, tile);
   218 
   218 
   219 		/* Terrain type */
   219 		/* Terrain type */
   367 		/* XXX: This is for debugging purposes really, and shouldn't stay. */
   367 		/* XXX: This is for debugging purposes really, and shouldn't stay. */
   368 		DrawGroundSprite(SPR_SHADOW_CELL, PAL_NONE);
   368 		DrawGroundSprite(SPR_SHADOW_CELL, PAL_NONE);
   369 	} else {
   369 	} else {
   370 		/* Limit the building stage to the number of stages supplied. */
   370 		/* Limit the building stage to the number of stages supplied. */
   371 		byte stage = GetHouseBuildingStage(ti->tile);
   371 		byte stage = GetHouseBuildingStage(ti->tile);
   372 		stage = clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1);
   372 		stage = Clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1);
   373 		DrawTileLayout(ti, group, stage, house_id);
   373 		DrawTileLayout(ti, group, stage, house_id);
   374 	}
   374 	}
   375 }
   375 }
   376 
   376 
   377 void AnimateNewHouseTile(TileIndex tile)
   377 void AnimateNewHouseTile(TileIndex tile)
   380 	byte animation_speed = hs->animation_speed;
   380 	byte animation_speed = hs->animation_speed;
   381 	bool frame_set_by_callback = false;
   381 	bool frame_set_by_callback = false;
   382 
   382 
   383 	if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) {
   383 	if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) {
   384 		uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
   384 		uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
   385 		if (callback_res != CALLBACK_FAILED) animation_speed = clamp(callback_res & 0xFF, 2, 16);
   385 		if (callback_res != CALLBACK_FAILED) animation_speed = Clamp(callback_res & 0xFF, 2, 16);
   386 	}
   386 	}
   387 
   387 
   388 	/* An animation speed of 2 means the animation frame changes 4 ticks, and
   388 	/* An animation speed of 2 means the animation frame changes 4 ticks, and
   389 	 * increasing this value by one doubles the wait. 2 is the minimum value
   389 	 * increasing this value by one doubles the wait. 2 is the minimum value
   390 	 * allowed for animation_speed, which corresponds to 120ms, and 16 is the
   390 	 * allowed for animation_speed, which corresponds to 120ms, and 16 is the