mirror of https://github.com/OpenTTD/OpenTTD
(svn r24452) [1.2] -Backport from trunk:
- Fix: In some cases ships could be covered with land [FS#5254] (r24449, r24439) - Fix: Copy constructor and assignment operator cannot be implicit template specialisations [FS#5255] (r24448) - Fix: Make (non-refittable) vehicles with invalid default cargo unavailable [FS#5256] (r24438) - Change: Allow passing C(XX)- and LDFLAGS to the compilation of helper binaries such as depend, strgen and settingsgen (r24432, r24429, r24427)release/1.2
parent
54ad65d246
commit
83d5c6a88d
14
config.lib
14
config.lib
|
@ -164,7 +164,7 @@ set_default() {
|
||||||
with_ccache
|
with_ccache
|
||||||
with_grfcodec
|
with_grfcodec
|
||||||
with_nforenum
|
with_nforenum
|
||||||
CC CXX CFLAGS CXXFLAGS LDFLAGS"
|
CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_BUILD CXXFLAGS_BUILD LDFLAGS_BUILD"
|
||||||
}
|
}
|
||||||
|
|
||||||
detect_params() {
|
detect_params() {
|
||||||
|
@ -442,6 +442,9 @@ detect_params() {
|
||||||
CFLAGS=* | --CFLAGS=*) CFLAGS="$optarg";;
|
CFLAGS=* | --CFLAGS=*) CFLAGS="$optarg";;
|
||||||
CXXFLAGS=* | --CXXFLAGS=*) CXXFLAGS="$optarg";;
|
CXXFLAGS=* | --CXXFLAGS=*) CXXFLAGS="$optarg";;
|
||||||
LDFLAGS=* | --LDFLAGS=*) LDFLAGS="$optarg";;
|
LDFLAGS=* | --LDFLAGS=*) LDFLAGS="$optarg";;
|
||||||
|
CFLAGS_BUILD=* | --CFLAGS_BUILD=*) CFLAGS_BUILD="$optarg";;
|
||||||
|
CXXFLAGS_BUILD=* | --CXXFLAGS_BUILD=*) CXXFLAGS_BUILD="$optarg";;
|
||||||
|
LDFLAGS_BUILD=* | --LDFLAGS_BUILD=*) LDFLAGS_BUILD="$optarg";;
|
||||||
|
|
||||||
--ignore-extra-parameters) ignore_extra_parameters="1";;
|
--ignore-extra-parameters) ignore_extra_parameters="1";;
|
||||||
|
|
||||||
|
@ -1386,11 +1389,11 @@ make_compiler_cflags() {
|
||||||
|
|
||||||
make_cflags_and_ldflags() {
|
make_cflags_and_ldflags() {
|
||||||
# General CFlags for BUILD
|
# General CFlags for BUILD
|
||||||
CFLAGS_BUILD=""
|
CFLAGS_BUILD="$CFLAGS_BUILD"
|
||||||
# Special CXXFlags for BUILD
|
# Special CXXFlags for BUILD
|
||||||
CXXFLAGS_BUILD=""
|
CXXFLAGS_BUILD="$CXXFLAGS_BUILD"
|
||||||
# LDFLAGS for BUILD
|
# LDFLAGS for BUILD
|
||||||
LDFLAGS_BUILD=""
|
LDFLAGS_BUILD="$LDFLAGS_BUILD"
|
||||||
# FEATURES for BUILD (lto)
|
# FEATURES for BUILD (lto)
|
||||||
FEATURES_BUILD=""
|
FEATURES_BUILD=""
|
||||||
# General CFlags for HOST
|
# General CFlags for HOST
|
||||||
|
@ -1807,6 +1810,9 @@ make_cflags_and_ldflags() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log 1 "using CFLAGS_BUILD... $CFLAGS_BUILD"
|
||||||
|
log 1 "using CXXFLAGS_BUILD... $CXXFLAGS_BUILD"
|
||||||
|
log 1 "using LDFLAGS_BUILD... $LDFLAGS_BUILD"
|
||||||
log 1 "using CFLAGS... $CFLAGS"
|
log 1 "using CFLAGS... $CFLAGS"
|
||||||
log 1 "using CXXFLAGS... $CXXFLAGS"
|
log 1 "using CXXFLAGS... $CXXFLAGS"
|
||||||
log 1 "using LDFLAGS... $LIBS $LDFLAGS"
|
log 1 "using LDFLAGS... $LIBS $LDFLAGS"
|
||||||
|
|
|
@ -39,21 +39,39 @@ public:
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
* @param other The other vector to copy.
|
* @param other The other vector to copy.
|
||||||
*/
|
*/
|
||||||
|
SmallVector(const SmallVector &other) : data(NULL), items(0), capacity(0)
|
||||||
|
{
|
||||||
|
this->Assign(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic copy constructor.
|
||||||
|
* @param other The other vector to copy.
|
||||||
|
*/
|
||||||
template <uint X>
|
template <uint X>
|
||||||
SmallVector(const SmallVector<T, X> &other) : data(NULL), items(0), capacity(0)
|
SmallVector(const SmallVector<T, X> &other) : data(NULL), items(0), capacity(0)
|
||||||
{
|
{
|
||||||
MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
|
this->Assign(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assignment.
|
* Assignment.
|
||||||
* @param other The new vector that.
|
* @param other The other vector to assign.
|
||||||
|
*/
|
||||||
|
SmallVector &operator=(const SmallVector &other)
|
||||||
|
{
|
||||||
|
this->Assign(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic assignment.
|
||||||
|
* @param other The other vector to assign.
|
||||||
*/
|
*/
|
||||||
template <uint X>
|
template <uint X>
|
||||||
SmallVector &operator=(const SmallVector<T, X> &other)
|
SmallVector &operator=(const SmallVector<T, X> &other)
|
||||||
{
|
{
|
||||||
this->Reset();
|
this->Assign(other);
|
||||||
MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +80,18 @@ public:
|
||||||
free(this->data);
|
free(this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign items from other vector.
|
||||||
|
*/
|
||||||
|
template <uint X>
|
||||||
|
inline void Assign(const SmallVector<T, X> &other)
|
||||||
|
{
|
||||||
|
if ((const void *)&other == (void *)this) return;
|
||||||
|
|
||||||
|
this->Clear();
|
||||||
|
if (other.Length() > 0) MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all items from the list.
|
* Remove all items from the list.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -910,7 +910,10 @@ int main(int argc, char *argv[])
|
||||||
size = ftell(src);
|
size = ftell(src);
|
||||||
rewind(src);
|
rewind(src);
|
||||||
content = (char*)malloc(size * sizeof(*content));
|
content = (char*)malloc(size * sizeof(*content));
|
||||||
fread(content, 1, size, src);
|
if (fread(content, 1, size, src) != (size_t)size) {
|
||||||
|
fprintf(stderr, "Could not read %s\n", filename);
|
||||||
|
exit(-2);
|
||||||
|
}
|
||||||
fclose(src);
|
fclose(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,7 +922,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (size != 0) {
|
if (size != 0) {
|
||||||
src = fopen(backup, "wb");
|
src = fopen(backup, "wb");
|
||||||
fwrite(content, 1, size, src);
|
if (fwrite(content, 1, size, src) != (size_t)size) {
|
||||||
|
fprintf(stderr, "Could not write %s\n", filename);
|
||||||
|
exit(-2);
|
||||||
|
}
|
||||||
fclose(src);
|
fclose(src);
|
||||||
|
|
||||||
/* Then append it to the real file. */
|
/* Then append it to the real file. */
|
||||||
|
|
|
@ -1041,7 +1041,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
} else if (_cur.grffile->grf_version >= 8) {
|
} else if (_cur.grffile->grf_version >= 8) {
|
||||||
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
|
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
|
||||||
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
|
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
|
||||||
} else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
|
} else if (ctype < NUM_CARGO) {
|
||||||
/* Use untranslated cargo. */
|
/* Use untranslated cargo. */
|
||||||
ei->cargo_type = ctype;
|
ei->cargo_type = ctype;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1276,7 +1276,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
} else if (_cur.grffile->grf_version >= 8) {
|
} else if (_cur.grffile->grf_version >= 8) {
|
||||||
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
|
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
|
||||||
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
|
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
|
||||||
} else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
|
} else if (ctype < NUM_CARGO) {
|
||||||
/* Use untranslated cargo. */
|
/* Use untranslated cargo. */
|
||||||
ei->cargo_type = ctype;
|
ei->cargo_type = ctype;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1454,7 +1454,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
} else if (_cur.grffile->grf_version >= 8) {
|
} else if (_cur.grffile->grf_version >= 8) {
|
||||||
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
|
/* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
|
||||||
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
|
ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
|
||||||
} else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
|
} else if (ctype < NUM_CARGO) {
|
||||||
/* Use untranslated cargo. */
|
/* Use untranslated cargo. */
|
||||||
ei->cargo_type = ctype;
|
ei->cargo_type = ctype;
|
||||||
} else {
|
} else {
|
||||||
|
@ -8205,6 +8205,9 @@ static void CalculateRefitMasks()
|
||||||
only_defaultcargo = (ei->refit_mask == 0);
|
only_defaultcargo = (ei->refit_mask == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clear invalid cargoslots (from default vehicles or pre-NewCargo GRFs) */
|
||||||
|
if (!HasBit(_cargo_mask, ei->cargo_type)) ei->cargo_type = CT_INVALID;
|
||||||
|
|
||||||
/* Ensure that the vehicle is either not refittable, or that the default cargo is one of the refittable cargoes.
|
/* Ensure that the vehicle is either not refittable, or that the default cargo is one of the refittable cargoes.
|
||||||
* Note: Vehicles refittable to no cargo are handle differently to vehicle refittable to a single cargo. The latter might have subtypes. */
|
* Note: Vehicles refittable to no cargo are handle differently to vehicle refittable to a single cargo. The latter might have subtypes. */
|
||||||
if (!only_defaultcargo && (e->type != VEH_SHIP || e->u.ship.old_refittable) && ei->cargo_type != CT_INVALID && !HasBit(ei->refit_mask, ei->cargo_type)) {
|
if (!only_defaultcargo && (e->type != VEH_SHIP || e->u.ship.old_refittable) && ei->cargo_type != CT_INVALID && !HasBit(ei->refit_mask, ei->cargo_type)) {
|
||||||
|
|
|
@ -2604,7 +2604,7 @@ set_ground:
|
||||||
static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
||||||
{
|
{
|
||||||
/* Case of half tile slope with water. */
|
/* Case of half tile slope with water. */
|
||||||
if (mode == TRANSPORT_WATER && IsPlainRail(tile) && GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
if (mode == TRANSPORT_WATER && IsPlainRail(tile) && GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(GetTileSlope(tile))) {
|
||||||
TrackBits tb = GetTrackBits(tile);
|
TrackBits tb = GetTrackBits(tile);
|
||||||
switch (tb) {
|
switch (tb) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
@ -2925,6 +2925,14 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, int z_old
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test-procedure for HasVehicleOnPos to check for a ship.
|
||||||
|
*/
|
||||||
|
static Vehicle *EnsureNoShipProc(Vehicle *v, void *data)
|
||||||
|
{
|
||||||
|
return v->type == VEH_SHIP ? v : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
||||||
{
|
{
|
||||||
int z_old;
|
int z_old;
|
||||||
|
@ -2934,6 +2942,9 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int
|
||||||
/* Is there flat water on the lower halftile that must be cleared expensively? */
|
/* Is there flat water on the lower halftile that must be cleared expensively? */
|
||||||
bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
|
bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
|
||||||
|
|
||||||
|
/* Allow clearing the water only if there is no ship */
|
||||||
|
if (was_water && HasVehicleOnPos(tile, NULL, &EnsureNoShipProc)) return_cmd_error(STR_ERROR_SHIP_IN_THE_WAY);
|
||||||
|
|
||||||
/* First test autoslope. However if it succeeds we still have to test the rest, because non-autoslope terraforming is cheaper. */
|
/* First test autoslope. However if it succeeds we still have to test the rest, because non-autoslope terraforming is cheaper. */
|
||||||
CommandCost autoslope_result = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, rail_bits);
|
CommandCost autoslope_result = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, rail_bits);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue