mirror of https://github.com/OpenTTD/OpenTTD
(svn r22224) [1.1] -Backport from trunk:
- Fix: Compilation when compiling with --disable-ai (r22222) - Fix: When downloading a file via HTTP failed mid-way and OpenTTD fell back to the old system the partial downloaded amount would be counted twice [FS#4543] (r22208) - Fix: The 'center' (for movement) of vehicles is (currently still) always at 4/8th original vehicle length from the front, so trains should stop at the same location regardless of the length of the front engine [FS#4545] (r22206) - Fix: Make the base costs for building and demolishing NewObjects also local to the individual NewGRFs (r22204) - Fix: Removing a station order could stop when removing first automatic order (r22200) - Fix: Invalidate the object build window when using the date cheat (r22193)release/1.1
parent
01bc61309f
commit
30cf8d1971
|
@ -168,7 +168,7 @@ public:
|
||||||
static void GameLoop() {}
|
static void GameLoop() {}
|
||||||
static bool HasAI(const struct ContentInfo *ci, bool md5sum) { return false; }
|
static bool HasAI(const struct ContentInfo *ci, bool md5sum) { return false; }
|
||||||
static void Rescan() {}
|
static void Rescan() {}
|
||||||
static char *GetConsoleList(char *p, const char *last) { return p; }
|
static char *GetConsoleList(char *p, const char *last, bool newest_only = false) { return p; }
|
||||||
static void nop() { }
|
static void nop() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -328,7 +328,7 @@ void AddArticulatedParts(Vehicle *first)
|
||||||
v = rv;
|
v = rv;
|
||||||
|
|
||||||
rv->subtype = 0;
|
rv->subtype = 0;
|
||||||
gcache->cached_veh_length = 8; // Callback is called when the consist is finished
|
gcache->cached_veh_length = VEHICLE_LENGTH; // Callback is called when the consist is finished
|
||||||
rv->state = RVSB_IN_DEPOT;
|
rv->state = RVSB_IN_DEPOT;
|
||||||
|
|
||||||
rv->roadtype = front->roadtype;
|
rv->roadtype = front->roadtype;
|
||||||
|
|
|
@ -125,6 +125,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
|
||||||
EnginesMonthlyLoop();
|
EnginesMonthlyLoop();
|
||||||
SetWindowDirty(WC_STATUS_BAR, 0);
|
SetWindowDirty(WC_STATUS_BAR, 0);
|
||||||
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
||||||
|
InvalidateWindowClassesData(WC_BUILD_OBJECT, 0);
|
||||||
ResetSignalVariant();
|
ResetSignalVariant();
|
||||||
return _cur_year;
|
return _cur_year;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct GroundVehicleCache {
|
||||||
/* Cached NewGRF values, recalculated on load and each time a vehicle is added to/removed from the consist. */
|
/* Cached NewGRF values, recalculated on load and each time a vehicle is added to/removed from the consist. */
|
||||||
uint16 cached_total_length; ///< Length of the whole vehicle (valid only for the first engine).
|
uint16 cached_total_length; ///< Length of the whole vehicle (valid only for the first engine).
|
||||||
EngineID first_engine; ///< Cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself.
|
EngineID first_engine; ///< Cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself.
|
||||||
uint8 cached_veh_length; ///< Length of this vehicle in units of 1/8 of normal length. It is cached because this can be set by a callback.
|
uint8 cached_veh_length; ///< Length of this vehicle in units of 1/VEHICLE_LENGTH of normal length. It is cached because this can be set by a callback.
|
||||||
|
|
||||||
/* Cached UI information. */
|
/* Cached UI information. */
|
||||||
uint16 last_speed; ///< The last speed we did display, so we only have to redraw when this changes.
|
uint16 last_speed; ///< The last speed we did display, so we only have to redraw when this changes.
|
||||||
|
|
|
@ -453,7 +453,7 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_CONTENT)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->OnDownloadProgress(this->curInfo, (uint)toRead);
|
this->OnDownloadProgress(this->curInfo, (int)toRead);
|
||||||
|
|
||||||
if (toRead == 0) this->AfterDownload();
|
if (toRead == 0) this->AfterDownload();
|
||||||
}
|
}
|
||||||
|
@ -526,6 +526,10 @@ void ClientNetworkContentSocketHandler::OnFailure()
|
||||||
this->http_response_index = -2;
|
this->http_response_index = -2;
|
||||||
|
|
||||||
if (this->curFile != NULL) {
|
if (this->curFile != NULL) {
|
||||||
|
/* Revert the download progress when we are going for the old system. */
|
||||||
|
long size = ftell(this->curFile);
|
||||||
|
if (size > 0) this->OnDownloadProgress(this->curInfo, (int)-size);
|
||||||
|
|
||||||
fclose(this->curFile);
|
fclose(this->curFile);
|
||||||
this->curFile = NULL;
|
this->curFile = NULL;
|
||||||
}
|
}
|
||||||
|
@ -559,7 +563,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
|
||||||
this->OnFailure();
|
this->OnFailure();
|
||||||
} else {
|
} else {
|
||||||
/* Just received the data. */
|
/* Just received the data. */
|
||||||
this->OnDownloadProgress(this->curInfo, (uint)length);
|
this->OnDownloadProgress(this->curInfo, (int)length);
|
||||||
}
|
}
|
||||||
/* Nothing more to do now. */
|
/* Nothing more to do now. */
|
||||||
return;
|
return;
|
||||||
|
@ -1023,7 +1027,7 @@ void ClientNetworkContentSocketHandler::OnReceiveContentInfo(const ContentInfo *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientNetworkContentSocketHandler::OnDownloadProgress(const ContentInfo *ci, uint bytes)
|
void ClientNetworkContentSocketHandler::OnDownloadProgress(const ContentInfo *ci, int bytes)
|
||||||
{
|
{
|
||||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||||
ContentCallback *cb = *iter;
|
ContentCallback *cb = *iter;
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct ContentCallback {
|
||||||
* @param ci the content info of the file
|
* @param ci the content info of the file
|
||||||
* @param bytes the number of bytes downloaded since the previous call
|
* @param bytes the number of bytes downloaded since the previous call
|
||||||
*/
|
*/
|
||||||
virtual void OnDownloadProgress(const ContentInfo *ci, uint bytes) {}
|
virtual void OnDownloadProgress(const ContentInfo *ci, int bytes) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We have finished downloading a file
|
* We have finished downloading a file
|
||||||
|
@ -89,7 +89,7 @@ protected:
|
||||||
void OnConnect(bool success);
|
void OnConnect(bool success);
|
||||||
void OnDisconnect();
|
void OnDisconnect();
|
||||||
void OnReceiveContentInfo(const ContentInfo *ci);
|
void OnReceiveContentInfo(const ContentInfo *ci);
|
||||||
void OnDownloadProgress(const ContentInfo *ci, uint bytes);
|
void OnDownloadProgress(const ContentInfo *ci, int bytes);
|
||||||
void OnDownloadComplete(ContentID cid);
|
void OnDownloadComplete(ContentID cid);
|
||||||
|
|
||||||
void OnFailure();
|
void OnFailure();
|
||||||
|
|
|
@ -175,7 +175,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnDownloadProgress(const ContentInfo *ci, uint bytes)
|
virtual void OnDownloadProgress(const ContentInfo *ci, int bytes)
|
||||||
{
|
{
|
||||||
if (ci->id != this->cur_id) {
|
if (ci->id != this->cur_id) {
|
||||||
strecpy(this->name, ci->filename, lastof(this->name));
|
strecpy(this->name, ci->filename, lastof(this->name));
|
||||||
|
|
|
@ -6901,7 +6901,7 @@ static bool HandleNode(byte type, uint32 id, ByteReader *buf, AllowedSubtags sub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
grfmsg(2, "StaticGRFInfo: unkown type/id combination found, type=%c, id=%x", type, id);
|
grfmsg(2, "StaticGRFInfo: unknown type/id combination found, type=%c, id=%x", type, id);
|
||||||
return SkipUnknownInfo(buf, type);
|
return SkipUnknownInfo(buf, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,13 +74,13 @@ struct ObjectSpec {
|
||||||
* Get the cost for building a structure of this type.
|
* Get the cost for building a structure of this type.
|
||||||
* @return The cost for building.
|
* @return The cost for building.
|
||||||
*/
|
*/
|
||||||
Money GetBuildCost() const { return (_price[PR_BUILD_OBJECT] * this->build_cost_multiplier); }
|
Money GetBuildCost() const { return GetPrice(PR_BUILD_OBJECT, this->build_cost_multiplier, this->grf_prop.grffile, 0); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cost for clearing a structure of this type.
|
* Get the cost for clearing a structure of this type.
|
||||||
* @return The cost for clearing.
|
* @return The cost for clearing.
|
||||||
*/
|
*/
|
||||||
Money GetClearCost() const { return (_price[PR_CLEAR_OBJECT] * this->clear_cost_multiplier); }
|
Money GetClearCost() const { return GetPrice(PR_CLEAR_OBJECT, this->clear_cost_multiplier, this->grf_prop.grffile, 0); }
|
||||||
|
|
||||||
bool IsAvailable() const;
|
bool IsAvailable() const;
|
||||||
uint Index() const;
|
uint Index() const;
|
||||||
|
|
|
@ -1637,6 +1637,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
|
||||||
int id = -1;
|
int id = -1;
|
||||||
FOR_VEHICLE_ORDERS(v, order) {
|
FOR_VEHICLE_ORDERS(v, order) {
|
||||||
id++;
|
id++;
|
||||||
|
restart:
|
||||||
|
|
||||||
OrderType ot = order->GetType();
|
OrderType ot = order->GetType();
|
||||||
if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
|
if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
|
||||||
|
@ -1646,9 +1647,10 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
|
||||||
* dummy orders. They should just vanish. Also check the actual order
|
* dummy orders. They should just vanish. Also check the actual order
|
||||||
* type as ot is currently OT_GOTO_STATION. */
|
* type as ot is currently OT_GOTO_STATION. */
|
||||||
if (order->IsType(OT_AUTOMATIC)) {
|
if (order->IsType(OT_AUTOMATIC)) {
|
||||||
|
order = order->next; // DeleteOrder() invalidates current order
|
||||||
DeleteOrder(v, id);
|
DeleteOrder(v, id);
|
||||||
id--;
|
if (order != NULL) goto restart;
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
order->MakeDummy();
|
order->MakeDummy();
|
||||||
|
|
|
@ -100,7 +100,7 @@ int RoadVehicle::GetDisplayImageWidth(Point *offset) const
|
||||||
offset->x = reference_width / 2;
|
offset->x = reference_width / 2;
|
||||||
offset->y = 0;
|
offset->y = 0;
|
||||||
}
|
}
|
||||||
return this->gcache.cached_veh_length * reference_width / 8;
|
return this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpriteID GetRoadVehIcon(EngineID engine)
|
static SpriteID GetRoadVehIcon(EngineID engine)
|
||||||
|
@ -161,11 +161,11 @@ void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID eng
|
||||||
*/
|
*/
|
||||||
static uint GetRoadVehLength(const RoadVehicle *v)
|
static uint GetRoadVehLength(const RoadVehicle *v)
|
||||||
{
|
{
|
||||||
uint length = 8;
|
uint length = VEHICLE_LENGTH;
|
||||||
|
|
||||||
uint16 veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, v->engine_type, v);
|
uint16 veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, v->engine_type, v);
|
||||||
if (veh_len != CALLBACK_FAILED) {
|
if (veh_len != CALLBACK_FAILED) {
|
||||||
length -= Clamp(veh_len, 0, 7);
|
length -= Clamp(veh_len, 0, VEHICLE_LENGTH - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
|
@ -262,7 +262,7 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
||||||
|
|
||||||
v->roadtype = HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
|
v->roadtype = HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
|
||||||
v->compatible_roadtypes = RoadTypeToRoadTypes(v->roadtype);
|
v->compatible_roadtypes = RoadTypeToRoadTypes(v->roadtype);
|
||||||
v->gcache.cached_veh_length = 8;
|
v->gcache.cached_veh_length = VEHICLE_LENGTH;
|
||||||
|
|
||||||
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
|
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,8 @@ extern const PriceBaseSpec _price_base_specs[] = {
|
||||||
{ 5600, PCAT_RUNNING, GSF_SHIPS, INVALID_PRICE }, ///< PR_RUNNING_SHIP
|
{ 5600, PCAT_RUNNING, GSF_SHIPS, INVALID_PRICE }, ///< PR_RUNNING_SHIP
|
||||||
{1000000, PCAT_CONSTRUCTION, GSF_END, INVALID_PRICE }, ///< PR_BUILD_INDUSTRY
|
{1000000, PCAT_CONSTRUCTION, GSF_END, INVALID_PRICE }, ///< PR_BUILD_INDUSTRY
|
||||||
{ 1600, PCAT_CONSTRUCTION, GSF_END, PR_CLEAR_HOUSE }, ///< PR_CLEAR_INDUSTRY
|
{ 1600, PCAT_CONSTRUCTION, GSF_END, PR_CLEAR_HOUSE }, ///< PR_CLEAR_INDUSTRY
|
||||||
{ 40, PCAT_CONSTRUCTION, GSF_END, PR_CLEAR_ROUGH }, ///< PR_BUILD_OBJECT
|
{ 40, PCAT_CONSTRUCTION, GSF_OBJECTS, PR_CLEAR_ROUGH }, ///< PR_BUILD_OBJECT
|
||||||
{ 40, PCAT_CONSTRUCTION, GSF_END, PR_CLEAR_ROUGH }, ///< PR_CLEAR_OBJECT
|
{ 40, PCAT_CONSTRUCTION, GSF_OBJECTS, PR_CLEAR_ROUGH }, ///< PR_CLEAR_OBJECT
|
||||||
{ 600, PCAT_CONSTRUCTION, GSF_END, PR_BUILD_DEPOT_TRAIN }, ///< PR_BUILD_WAYPOINT_RAIL
|
{ 600, PCAT_CONSTRUCTION, GSF_END, PR_BUILD_DEPOT_TRAIN }, ///< PR_BUILD_WAYPOINT_RAIL
|
||||||
{ 80, PCAT_CONSTRUCTION, GSF_END, PR_CLEAR_DEPOT_TRAIN }, ///< PR_CLEAR_WAYPOINT_RAIL
|
{ 80, PCAT_CONSTRUCTION, GSF_END, PR_CLEAR_DEPOT_TRAIN }, ///< PR_CLEAR_WAYPOINT_RAIL
|
||||||
{ 350, PCAT_CONSTRUCTION, GSF_END, PR_BUILD_STATION_DOCK }, ///< PR_BUILD_WAYPOINT_BUOY
|
{ 350, PCAT_CONSTRUCTION, GSF_END, PR_BUILD_STATION_DOCK }, ///< PR_BUILD_WAYPOINT_BUOY
|
||||||
|
|
|
@ -240,7 +240,7 @@ void Train::ConsistChanged(bool same_length)
|
||||||
veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, u->engine_type, u);
|
veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, u->engine_type, u);
|
||||||
}
|
}
|
||||||
if (veh_len == CALLBACK_FAILED) veh_len = rvi_u->shorten_factor;
|
if (veh_len == CALLBACK_FAILED) veh_len = rvi_u->shorten_factor;
|
||||||
veh_len = 8 - Clamp(veh_len, 0, 7);
|
veh_len = VEHICLE_LENGTH - Clamp(veh_len, 0, VEHICLE_LENGTH - 1);
|
||||||
|
|
||||||
/* verify length hasn't changed */
|
/* verify length hasn't changed */
|
||||||
if (same_length && veh_len != u->gcache.cached_veh_length) RailVehicleLengthChanged(u);
|
if (same_length && veh_len != u->gcache.cached_veh_length) RailVehicleLengthChanged(u);
|
||||||
|
@ -313,8 +313,11 @@ int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, i
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Subtract half the front vehicle length of the train so we get the real
|
/* Subtract half the front vehicle length of the train so we get the real
|
||||||
* stop location of the train. */
|
* stop location of the train.
|
||||||
return stop - (v->gcache.cached_veh_length + 1) / 2;
|
* Actually, the center of all vehicles is half a normal vehicle's length
|
||||||
|
* from the front of the vehicle, so even in case the vehicle is 1/8th
|
||||||
|
* long, the center is still at 1/2 of VEHICLE_LENGTH. Basically FS#3569. */
|
||||||
|
return stop - VEHICLE_LENGTH / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -461,7 +464,7 @@ int Train::GetDisplayImageWidth(Point *offset) const
|
||||||
offset->x = reference_width / 2;
|
offset->x = reference_width / 2;
|
||||||
offset->y = vehicle_pitch;
|
offset->y = vehicle_pitch;
|
||||||
}
|
}
|
||||||
return this->gcache.cached_veh_length * reference_width / 8;
|
return this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction)
|
static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction)
|
||||||
|
@ -3403,8 +3406,13 @@ static bool TrainApproachingLineEnd(Train *v, bool signal)
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do not reverse when approaching red signal */
|
/* Do not reverse when approaching red signal. Make sure the vehicle's front
|
||||||
if (!signal && x + (v->gcache.cached_veh_length + 1) / 2 >= TILE_SIZE) {
|
* does not cross the tile boundary when we do reverse, but as the vehicle's
|
||||||
|
* location is based on their center, use half a vehicle's length as offset.
|
||||||
|
* Actually, the center of all vehicles is half a normal vehicle's length
|
||||||
|
* from the front of the vehicle, so even in case the vehicle is 1/8th
|
||||||
|
* long, the center is still at 1/2 of VEHICLE_LENGTH. Basically FS#3569. */
|
||||||
|
if (!signal && x + VEHICLE_LENGTH / 2 >= TILE_SIZE) {
|
||||||
/* we are too near the tile end, reverse now */
|
/* we are too near the tile end, reverse now */
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
ReverseTrainDirection(v);
|
ReverseTrainDirection(v);
|
||||||
|
|
|
@ -67,6 +67,9 @@ enum DepotCommand {
|
||||||
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 32; ///< The maximum length of a vehicle name in characters including '\0'
|
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 32; ///< The maximum length of a vehicle name in characters including '\0'
|
||||||
static const uint MAX_LENGTH_VEHICLE_NAME_PIXELS = 150; ///< The maximum length of a vehicle name in pixels
|
static const uint MAX_LENGTH_VEHICLE_NAME_PIXELS = 150; ///< The maximum length of a vehicle name in pixels
|
||||||
|
|
||||||
|
/** The length of a vehicle in tile units. */
|
||||||
|
static const uint VEHICLE_LENGTH = 8;
|
||||||
|
|
||||||
/** Vehicle acceleration models. */
|
/** Vehicle acceleration models. */
|
||||||
enum AccelerationModel {
|
enum AccelerationModel {
|
||||||
AM_ORIGINAL,
|
AM_ORIGINAL,
|
||||||
|
|
Loading…
Reference in New Issue