src/landscape.cpp
changeset 5919 2b58160d667d
parent 5847 9ce114e1d90d
child 6268 4b5241e5dd10
equal deleted inserted replaced
5918:602e158900a2 5919:2b58160d667d
   210 }
   210 }
   211 
   211 
   212 
   212 
   213 void DrawFoundation(TileInfo *ti, uint f)
   213 void DrawFoundation(TileInfo *ti, uint f)
   214 {
   214 {
   215 	uint32 sprite_base = SPR_SLOPES_BASE - 15;
   215 	SpriteID sprite_base = SPR_SLOPES_BASE - 15;
   216 	Slope slope;
   216 	Slope slope;
   217 	uint z;
   217 	uint z;
   218 
   218 
   219 	slope = GetFoundationSlope(ti->tile, &z);
   219 	slope = GetFoundationSlope(ti->tile, &z);
   220 	if (!HasFoundationNW(ti->tile, slope, z)) sprite_base += 22;
   220 	if (!HasFoundationNW(ti->tile, slope, z)) sprite_base += 22;
   221 	if (!HasFoundationNE(ti->tile, slope, z)) sprite_base += 44;
   221 	if (!HasFoundationNE(ti->tile, slope, z)) sprite_base += 44;
   222 
   222 
   223 	if (IsSteepSlope(ti->tileh)) {
   223 	if (IsSteepSlope(ti->tileh)) {
   224 		uint32 lower_base;
   224 		SpriteID lower_base;
   225 
   225 
   226 		// Lower part of foundation
   226 		// Lower part of foundation
   227 		lower_base = sprite_base;
   227 		lower_base = sprite_base;
   228 		if (lower_base == SPR_SLOPES_BASE - 15) lower_base = SPR_FOUNDATION_BASE;
   228 		if (lower_base == SPR_SLOPES_BASE - 15) lower_base = SPR_FOUNDATION_BASE;
   229 		AddSortableSpriteToDraw(
   229 		AddSortableSpriteToDraw(
   230 			lower_base + (ti->tileh & ~SLOPE_STEEP), ti->x, ti->y, 16, 16, 7, ti->z
   230 			lower_base + (ti->tileh & ~SLOPE_STEEP), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z
   231 		);
   231 		);
   232 		ti->z += TILE_HEIGHT;
   232 		ti->z += TILE_HEIGHT;
   233 		ti->tileh = _inclined_tileh[f - 15];
   233 		ti->tileh = _inclined_tileh[f - 15];
   234 		if (f < 15 + 8) {
   234 		if (f < 15 + 8) {
   235 			// inclined
   235 			// inclined
   236 			AddSortableSpriteToDraw(sprite_base + f, ti->x, ti->y, 16, 16, 1, ti->z);
   236 			AddSortableSpriteToDraw(sprite_base + f, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z);
   237 			OffsetGroundSprite(31, 9);
   237 			OffsetGroundSprite(31, 9);
   238 		} else if (f >= 15 + 8 + 4) {
   238 		} else if (f >= 15 + 8 + 4) {
   239 			// three corners raised
   239 			// three corners raised
   240 			uint32 upper = sprite_base + 15 + (f - 15 - 8 - 4) * 2;
   240 			SpriteID upper = sprite_base + 15 + (f - 15 - 8 - 4) * 2;
   241 
   241 
   242 			AddSortableSpriteToDraw(upper, ti->x, ti->y, 16, 16, 1, ti->z);
   242 			AddSortableSpriteToDraw(upper, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z);
   243 			AddChildSpriteScreen(upper + 1, 31, 9);
   243 			AddChildSpriteScreen(upper + 1, PAL_NONE, 31, 9);
   244 			OffsetGroundSprite(31, 9);
   244 			OffsetGroundSprite(31, 9);
   245 		} else {
   245 		} else {
   246 			// one corner raised
   246 			// one corner raised
   247 			OffsetGroundSprite(31, 1);
   247 			OffsetGroundSprite(31, 1);
   248 		}
   248 		}
   250 		if (f < 15) {
   250 		if (f < 15) {
   251 			// leveled foundation
   251 			// leveled foundation
   252 			// Use the original slope sprites if NW and NE borders should be visible
   252 			// Use the original slope sprites if NW and NE borders should be visible
   253 			if (sprite_base  == SPR_SLOPES_BASE - 15) sprite_base = SPR_FOUNDATION_BASE;
   253 			if (sprite_base  == SPR_SLOPES_BASE - 15) sprite_base = SPR_FOUNDATION_BASE;
   254 
   254 
   255 			AddSortableSpriteToDraw(sprite_base + f, ti->x, ti->y, 16, 16, 7, ti->z);
   255 			AddSortableSpriteToDraw(sprite_base + f, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
   256 			ti->z += TILE_HEIGHT;
   256 			ti->z += TILE_HEIGHT;
   257 			ti->tileh = SLOPE_FLAT;
   257 			ti->tileh = SLOPE_FLAT;
   258 			OffsetGroundSprite(31, 1);
   258 			OffsetGroundSprite(31, 1);
   259 		} else {
   259 		} else {
   260 			// inclined foundation
   260 			// inclined foundation
   261 			AddSortableSpriteToDraw(sprite_base + f, ti->x, ti->y, 16, 16, 1, ti->z);
   261 			AddSortableSpriteToDraw(sprite_base + f, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z);
   262 			ti->tileh = _inclined_tileh[f - 15];
   262 			ti->tileh = _inclined_tileh[f - 15];
   263 			OffsetGroundSprite(31, 9);
   263 			OffsetGroundSprite(31, 9);
   264 		}
   264 		}
   265 	}
   265 	}
   266 }
   266 }