mirror of https://github.com/OpenTTD/OpenTTD
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
parent
77a3900d5d
commit
e29d60b21b
7
newgrf.c
7
newgrf.c
|
@ -2457,6 +2457,8 @@ static void ParamSet(byte *buf, int len)
|
||||||
|
|
||||||
case 0x9E: /* Miscellaneous GRF features */
|
case 0x9E: /* Miscellaneous GRF features */
|
||||||
_misc_grf_features = res;
|
_misc_grf_features = res;
|
||||||
|
/* Set train list engine width */
|
||||||
|
_traininfo_vehicle_width = HASBIT(res, 3) ? 32 : 29;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -2648,6 +2650,11 @@ static void ResetNewGRFData(void)
|
||||||
// Add engine type to engine data. This is needed for the refit precalculation.
|
// Add engine type to engine data. This is needed for the refit precalculation.
|
||||||
AddTypeToEngines();
|
AddTypeToEngines();
|
||||||
|
|
||||||
|
/* Reset misc GRF features and train list display variables */
|
||||||
|
_misc_grf_features = 0;
|
||||||
|
_traininfo_vehicle_pitch = 0;
|
||||||
|
_traininfo_vehicle_width = 29;
|
||||||
|
|
||||||
InitializeSpriteGroupPool();
|
InitializeSpriteGroupPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ static const uint16 _cargo_classes[NUM_GLOBAL_CID] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int _traininfo_vehicle_pitch = 0;
|
int _traininfo_vehicle_pitch = 0;
|
||||||
|
int _traininfo_vehicle_width = 29;
|
||||||
|
|
||||||
// TODO: We don't support cargo-specific wagon overrides. Pretty exotic... ;-) --pasky
|
// TODO: We don't support cargo-specific wagon overrides. Pretty exotic... ;-) --pasky
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int _traininfo_vehicle_pitch;
|
extern int _traininfo_vehicle_pitch;
|
||||||
|
extern int _traininfo_vehicle_width;
|
||||||
|
|
||||||
VARDEF const uint32 _default_refitmasks[NUM_VEHICLE_TYPES];
|
VARDEF const uint32 _default_refitmasks[NUM_VEHICLE_TYPES];
|
||||||
VARDEF const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO];
|
VARDEF const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO];
|
||||||
|
|
10
train_gui.c
10
train_gui.c
|
@ -357,19 +357,19 @@ static void ShowBuildTrainWindow(TileIndex tile)
|
||||||
* @return Number of pixels across.
|
* @return Number of pixels across.
|
||||||
*/
|
*/
|
||||||
static int WagonLengthToPixels(int len) {
|
static int WagonLengthToPixels(int len) {
|
||||||
return (len * 29) / 8;
|
return (len * _traininfo_vehicle_width) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
|
static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
|
||||||
{
|
{
|
||||||
int dx = 0;
|
int dx = 0;
|
||||||
count *= 8;
|
count *= 29;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (--skip < 0) {
|
if (--skip < 0) {
|
||||||
int width = v->u.rail.cached_veh_length;
|
int width = v->u.rail.cached_veh_length;
|
||||||
|
|
||||||
if (dx + width <= count) {
|
if (WagonLengthToPixels(dx + width) <= count) {
|
||||||
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
||||||
DrawSprite(GetTrainImage(v, DIR_W) | pal, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
|
DrawSprite(GetTrainImage(v, DIR_W) | pal, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
|
||||||
if (v->index == selection)
|
if (v->index == selection)
|
||||||
|
@ -379,7 +379,7 @@ static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip,
|
||||||
}
|
}
|
||||||
|
|
||||||
v = v->next;
|
v = v->next;
|
||||||
} while (dx < count && v != NULL);
|
} while (WagonLengthToPixels(dx) < count && v != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawTrainDepotWindow(Window *w)
|
static void DrawTrainDepotWindow(Window *w)
|
||||||
|
@ -498,7 +498,7 @@ static int GetVehicleFromTrainDepotWndPt(const Window *w, int x, int y, GetDepot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x -= 29; /* free wagons don't have an initial loco. */
|
x -= _traininfo_vehicle_width; /* free wagons don't have an initial loco. */
|
||||||
|
|
||||||
/* and then the list of free wagons */
|
/* and then the list of free wagons */
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
|
|
Loading…
Reference in New Issue