(svn r18123) -Codechange: try our best to keep the vehicles within the build vehicle list/autoreplace lists instead of overflowing.

This commit is contained in:
rubidium
2009-11-16 17:58:46 +00:00
parent 5802dd5f40
commit d4774a2ce9
4 changed files with 21 additions and 3 deletions

View File

@@ -36,6 +36,7 @@
#include "effectvehicle_func.h"
#include "roadstop_base.h"
#include "cargotype.h"
#include "spritecache.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -140,7 +141,10 @@ SpriteID RoadVehicle::GetImage(Direction direction) const
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, SpriteID pal)
{
DrawSprite(GetRoadVehIcon(engine), pal, preferred_x, y);
SpriteID sprite = GetRoadVehIcon(engine);
const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs);
DrawSprite(sprite, pal, preferred_x, y);
}
static uint GetRoadVehLength(const RoadVehicle *v)