Update to 1.11.0-beta1
This commit is contained in:
+41
-5
@@ -609,12 +609,18 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN: {
|
||||
RailType rt = GetTileRailType(v->tile);
|
||||
return (HasPowerOnRail(Train::From(v)->railtype, rt) ? 0x100 : 0) | GetReverseRailTypeTranslation(rt, object->ro.grffile);
|
||||
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
||||
return ((rti->flags & RTFB_CATENARY) ? 0x200 : 0) |
|
||||
(HasPowerOnRail(Train::From(v)->railtype, rt) ? 0x100 : 0) |
|
||||
GetReverseRailTypeTranslation(rt, object->ro.grffile);
|
||||
}
|
||||
|
||||
case VEH_ROAD: {
|
||||
RoadType rt = GetRoadType(v->tile, GetRoadTramType(RoadVehicle::From(v)->roadtype));
|
||||
return 0x100 | GetReverseRoadTypeTranslation(rt, object->ro.grffile);
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
||||
return ((rti->flags & ROTFB_CATENARY) ? 0x200 : 0) |
|
||||
0x100 |
|
||||
GetReverseRoadTypeTranslation(rt, object->ro.grffile);
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -702,6 +708,36 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
return ret;
|
||||
}
|
||||
|
||||
case 0x63:
|
||||
/* Tile compatibility wrt. arbitrary track-type
|
||||
* Format:
|
||||
* bit 0: Type 'parameter' is known.
|
||||
* bit 1: Engines with type 'parameter' are compatible with this tile.
|
||||
* bit 2: Engines with type 'parameter' are powered on this tile.
|
||||
* bit 3: This tile has type 'parameter' or it is considered equivalent (alternate labels).
|
||||
*/
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN: {
|
||||
RailType param_type = GetRailTypeTranslation(parameter, object->ro.grffile);
|
||||
if (param_type == INVALID_RAILTYPE) return 0x00;
|
||||
RailType tile_type = GetTileRailType(v->tile);
|
||||
if (tile_type == param_type) return 0x0F;
|
||||
return (HasPowerOnRail(param_type, tile_type) ? 0x04 : 0x00) |
|
||||
(IsCompatibleRail(param_type, tile_type) ? 0x02 : 0x00) |
|
||||
0x01;
|
||||
}
|
||||
case VEH_ROAD: {
|
||||
RoadTramType rtt = GetRoadTramType(RoadVehicle::From(v)->roadtype);
|
||||
RoadType param_type = GetRoadTypeTranslation(rtt, parameter, object->ro.grffile);
|
||||
if (param_type == INVALID_ROADTYPE) return 0x00;
|
||||
RoadType tile_type = GetRoadType(v->tile, rtt);
|
||||
if (tile_type == param_type) return 0x0F;
|
||||
return (HasPowerOnRoad(param_type, tile_type) ? 0x06 : 0x00) |
|
||||
0x01;
|
||||
}
|
||||
default: return 0x00;
|
||||
}
|
||||
|
||||
case 0xFE:
|
||||
case 0xFF: {
|
||||
uint16 modflags = 0;
|
||||
@@ -940,8 +976,8 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
|
||||
if (totalsets == 0) return nullptr;
|
||||
|
||||
uint set = (v->cargo.StoredCount() * totalsets) / max((uint16)1, v->cargo_cap);
|
||||
set = min(set, totalsets - 1);
|
||||
uint set = (v->cargo.StoredCount() * totalsets) / std::max<uint16>(1u, v->cargo_cap);
|
||||
set = std::min(set, totalsets - 1);
|
||||
|
||||
return in_motion ? group->loaded[set] : group->loading[set];
|
||||
}
|
||||
@@ -1313,7 +1349,7 @@ void FillNewGRFVehicleCache(const Vehicle *v)
|
||||
{ 0x43, NCVV_COMPANY_INFORMATION },
|
||||
{ 0x4D, NCVV_POSITION_IN_VEHICLE },
|
||||
};
|
||||
assert_compile(NCVV_END == lengthof(cache_entries));
|
||||
static_assert(NCVV_END == lengthof(cache_entries));
|
||||
|
||||
/* Resolve all the variables, so their caches are set. */
|
||||
for (size_t i = 0; i < lengthof(cache_entries); i++) {
|
||||
|
||||
Reference in New Issue
Block a user