mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-02-02 09:04:29 +01:00
(svn r19928) [1.0] -Backport from trunk:
- Feature: Translated desktop shortcut comments (r19884) - Fix: Pay for the rail/road when constructing tunnels, bridges, depots and stations [FS#3859, FS#3827] (r19925, r19887, r19881) - Fix: Closing chatbox could cause glitches when news message was shown [FS#3865] (r19921)
This commit is contained in:
@@ -86,7 +86,7 @@ public:
|
||||
static int32 GetMaxSpeed(BridgeID bridge_id);
|
||||
|
||||
/**
|
||||
* Get the new cost of a bridge.
|
||||
* Get the new cost of a bridge, excluding the road and/or rail.
|
||||
* @param bridge_id The bridge to get the new cost of.
|
||||
* @param length The length of the bridge.
|
||||
* @pre IsValidBridge(bridge_id).
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
* functions may still be available if you return an older API version
|
||||
* in GetAPIVersion() in info.nut.
|
||||
*
|
||||
* \b 1.0.2
|
||||
*
|
||||
* Other changes:
|
||||
* \li AIBridge::GetPrice now returns the price of the bridge without the cost for the rail or road.
|
||||
*
|
||||
* \b 1.0.1
|
||||
*
|
||||
* API additions:
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "command_func.h"
|
||||
#include "economy_func.h"
|
||||
#include "bridge.h"
|
||||
#include "rail.h"
|
||||
#include "strings_func.h"
|
||||
#include "window_func.h"
|
||||
#include "sound_func.h"
|
||||
@@ -394,6 +395,13 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
||||
|
||||
bl = new GUIBridgeList();
|
||||
|
||||
Money infra_cost = 0;
|
||||
switch (transport_type) {
|
||||
case TRANSPORT_ROAD: infra_cost = (bridge_len + 2) * _price[PR_BUILD_ROAD] * 2; break;
|
||||
case TRANSPORT_RAIL: infra_cost = (bridge_len + 2) * RailBuildCost((RailType)road_rail_type); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
/* loop for all bridgetypes */
|
||||
for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
|
||||
if (CheckBridgeAvailability(brd_type, bridge_len).Succeeded()) {
|
||||
@@ -403,7 +411,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
||||
item->spec = GetBridgeSpec(brd_type);
|
||||
/* Add to terraforming & bulldozing costs the cost of the
|
||||
* bridge itself (not computed with DC_QUERY_COST) */
|
||||
item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8);
|
||||
item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8) + infra_cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3639,6 +3639,9 @@ STR_ERROR_CAN_T_PLACE_SIGN_HERE :{WHITE}Can't pl
|
||||
STR_ERROR_CAN_T_CHANGE_SIGN_NAME :{WHITE}Can't change sign name...
|
||||
STR_ERROR_CAN_T_DELETE_SIGN :{WHITE}Can't delete sign...
|
||||
|
||||
# Translatable comment for OpenTTD's desktop shortcut
|
||||
STR_DESKTOP_SHORTCUT_COMMENT :A clone of Transport Tycoon Deluxe
|
||||
|
||||
##id 0x2000
|
||||
# Town building names
|
||||
STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1 :Tall office block
|
||||
|
||||
@@ -490,24 +490,35 @@ struct NewsWindow : Window {
|
||||
virtual void OnInvalidateData(int data)
|
||||
{
|
||||
/* The chatbar has notified us that is was either created or closed */
|
||||
int newtop = this->top + this->chat_height - data;
|
||||
this->chat_height = data;
|
||||
this->SetWindowTop(newtop);
|
||||
}
|
||||
|
||||
virtual void OnTick()
|
||||
{
|
||||
/* Scroll up newsmessages from the bottom in steps of 4 pixels */
|
||||
int y = max(this->top - 4, _screen.height - this->height - this->status_height - this->chat_height);
|
||||
if (y == this->top) return;
|
||||
|
||||
if (this->viewport != NULL) this->viewport->top += y - this->top;
|
||||
|
||||
int diff = Delta(this->top, y);
|
||||
this->top = y;
|
||||
|
||||
SetDirtyBlocks(this->left, this->top, this->left + this->width, this->top + this->height + diff);
|
||||
int newtop = max(this->top - 4, _screen.height - this->height - this->status_height - this->chat_height);
|
||||
this->SetWindowTop(newtop);
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Moves the window so #newtop is new 'top' coordinate. Makes screen dirty where needed.
|
||||
* @param newtop new top coordinate
|
||||
*/
|
||||
void SetWindowTop(int newtop)
|
||||
{
|
||||
if (this->top == newtop) return;
|
||||
|
||||
int mintop = min(newtop, this->top);
|
||||
int maxtop = max(newtop, this->top);
|
||||
if (this->viewport != NULL) this->viewport->top += newtop - this->top;
|
||||
this->top = newtop;
|
||||
|
||||
SetDirtyBlocks(this->left, mintop, this->left + this->width, maxtop + this->height);
|
||||
}
|
||||
|
||||
StringID GetCompanyMessageString() const
|
||||
{
|
||||
switch (this->ni->subtype) {
|
||||
|
||||
@@ -871,6 +871,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||
}
|
||||
|
||||
cost.AddCost(_price[PR_BUILD_DEPOT_TRAIN]);
|
||||
cost.AddCost(RailBuildCost(railtype));
|
||||
return cost;
|
||||
}
|
||||
|
||||
|
||||
@@ -1020,6 +1020,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
|
||||
if (cost.Failed()) return cost;
|
||||
/* Add construction expenses. */
|
||||
cost.AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
|
||||
cost.AddCost(numtracks * plat_len * RailBuildCost(rt));
|
||||
|
||||
Station *st = NULL;
|
||||
CommandCost ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st);
|
||||
|
||||
@@ -465,6 +465,12 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
if (!(flags & DC_QUERY_COST) || (c != NULL && c->is_ai)) {
|
||||
bridge_len += 2; // begin and end tiles/ramps
|
||||
|
||||
switch (transport_type) {
|
||||
case TRANSPORT_ROAD: cost.AddCost(bridge_len * _price[PR_BUILD_ROAD] * 2); break;
|
||||
case TRANSPORT_RAIL: cost.AddCost(bridge_len * RailBuildCost(railtype)); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (c != NULL) bridge_len = CalcBridgeLenCostFactor(bridge_len);
|
||||
|
||||
cost.AddCost((int64)bridge_len * _price[PR_BUILD_BRIDGE] * GetBridgeSpec(bridge_type)->price >> 8);
|
||||
@@ -590,6 +596,13 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
|
||||
cost.AddCost(_price[PR_BUILD_TUNNEL]);
|
||||
cost.AddCost(ret);
|
||||
|
||||
/* Pay for the rail/road in the tunnel including entrances */
|
||||
switch (transport_type) {
|
||||
case TRANSPORT_ROAD: cost.AddCost((tiles + 2) * _price[PR_BUILD_ROAD] * 2); break;
|
||||
case TRANSPORT_RAIL: cost.AddCost((tiles + 2) * RailBuildCost(railtype)); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (transport_type == TRANSPORT_RAIL) {
|
||||
MakeRailTunnel(start_tile, _current_company, direction, railtype);
|
||||
|
||||
Reference in New Issue
Block a user