mirror of https://github.com/OpenTTD/OpenTTD
(svn r20165) -Feature: [NewGRF] Information (var 4A) about the current railtype a train is on.
parent
e809c05099
commit
2a3ec78d9f
|
@ -26,6 +26,7 @@
|
||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
#include "engine_base.h"
|
#include "engine_base.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
|
#include "newgrf_railtype.h"
|
||||||
|
|
||||||
struct WagonOverride {
|
struct WagonOverride {
|
||||||
EngineID *train_id;
|
EngineID *train_id;
|
||||||
|
@ -644,6 +645,12 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||||
case 0x48: return Engine::Get(v->engine_type)->flags; // Vehicle Type Info
|
case 0x48: return Engine::Get(v->engine_type)->flags; // Vehicle Type Info
|
||||||
case 0x49: return v->build_year;
|
case 0x49: return v->build_year;
|
||||||
|
|
||||||
|
case 0x4A: {
|
||||||
|
if (v->type != VEH_TRAIN) return 0;
|
||||||
|
RailType rt = GetTileRailType(v->tile);
|
||||||
|
return (HasPowerOnRail(Train::From(v)->railtype, rt) ? 0x100 : 0) | GetReverseRailTypeTranslation(rt, object->grffile);
|
||||||
|
}
|
||||||
|
|
||||||
/* Variables which use the parameter */
|
/* Variables which use the parameter */
|
||||||
case 0x60: // Count consist's engine ID occurance
|
case 0x60: // Count consist's engine ID occurance
|
||||||
//EngineID engine = GetNewEngineID(GetEngineGRF(v->engine_type), v->type, parameter);
|
//EngineID engine = GetNewEngineID(GetEngineGRF(v->engine_type), v->type, parameter);
|
||||||
|
|
|
@ -110,7 +110,7 @@ SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSp
|
||||||
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
|
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
|
||||||
{
|
{
|
||||||
/* No rail type table present, return rail type as-is */
|
/* No rail type table present, return rail type as-is */
|
||||||
if (grffile->railtype_max == 0) return railtype;
|
if (grffile == NULL || grffile->railtype_max == 0) return railtype;
|
||||||
|
|
||||||
/* Look for a matching rail type label in the table */
|
/* Look for a matching rail type label in the table */
|
||||||
RailTypeLabel label = GetRailTypeInfo(railtype)->label;
|
RailTypeLabel label = GetRailTypeInfo(railtype)->label;
|
||||||
|
|
Loading…
Reference in New Issue