1
0
Fork 0

(svn r19439) [1.0] -Backport from trunk:

- Fix: Custom group names are misaligned with default ones when using rtl languages [FS#3700] (r19438)
- Fix: With certain game settings one could clear tiles for free when building long roads (r19436)
- Fix: When loading a savegame created with a house NewGRF without that NewGRF available all houses became tall office blocks (r19435)
- Fix: Limit rail clearance earnings to 3/4s of rail build cost, to avoid money making loophole when rail build cost is less than rail removal earnings (r19433)
- Fix: Crash when the error message 'owned by <town>' was shown [FS#3696] (r19432)
- Feature: Append rail type speed limit (if set) to rail type selection list, and toolbar title (r19431)
release/1.0
rubidium 2010-03-16 20:54:26 +00:00
parent 821fe5c3ba
commit 9931557d89
11 changed files with 53 additions and 10 deletions

View File

@ -400,7 +400,7 @@ public:
/* draw the selected group in white, else we draw it in black */
SetDParam(0, g->index);
DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT, y1, STR_GROUP_NAME, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK);
DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 8, y1, STR_GROUP_NAME, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK);
/* draw the number of vehicles of the group */
SetDParam(0, g->num_vehicle);

View File

@ -4109,3 +4109,5 @@ STR_BUS :{BLACK}{BUS}
STR_LORRY :{BLACK}{LORRY}
STR_PLANE :{BLACK}{PLANE}
STR_SHIP :{BLACK}{SHIP}
STR_TOOLBAR_RAILTYPE_VELOCITY :{STRING} ({VELOCITY})

View File

@ -544,7 +544,7 @@ public:
this->detailed_msg = detailed_msg;
CompanyID company = (CompanyID)GetDParamX(this->decode_params, 2);
this->face = (this->detailed_msg == STR_ERROR_OWNED_BY && company <= MAX_COMPANIES) ? company : INVALID_COMPANY;
this->face = (this->detailed_msg == STR_ERROR_OWNED_BY && company < MAX_COMPANIES) ? company : INVALID_COMPANY;
const WindowDesc *desc = (face == INVALID_COMPANY) ? &_errmsg_desc : &_errmsg_face_desc;
assert(summary_msg != INVALID_STRING_ID);

View File

@ -136,7 +136,7 @@ uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte su
* @param entity_id of the entity being queried
* @return mapped id
*/
uint16 OverrideManagerBase::GetSubstituteID(byte entity_id)
uint16 OverrideManagerBase::GetSubstituteID(uint16 entity_id)
{
return mapping_ID[entity_id].substitute_id;
}

View File

@ -57,7 +57,7 @@ public:
void Add(uint8 local_id, uint32 grfid, uint entity_type);
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id);
uint16 GetSubstituteID(byte entity_id);
uint16 GetSubstituteID(uint16 entity_id);
virtual uint16 GetID(uint8 grf_local_id, uint32 grfid);
inline uint16 GetMaxMapping() { return max_new_entities; }

View File

@ -269,6 +269,22 @@ static inline Money RailBuildCost(RailType railtype)
return (_price[PR_BUILD_RAIL] * GetRailTypeInfo(railtype)->cost_multiplier) >> 3;
}
/**
* Returns the 'cost' of clearing the specified railtype.
* @param railtype The railtype being removed.
* @return The cost.
*/
static inline Money RailClearCost(RailType railtype)
{
/* Clearing rail in fact earns money, but if the build cost is set
* very low then a loophole exists where money can be made.
* In this case we limit the removal earnings to 3/4s of the build
* cost.
*/
assert(railtype < RAILTYPE_END);
return max(_price[PR_CLEAR_RAIL], -RailBuildCost(railtype) * 3 / 4);
}
/**
* Calculates the cost of rail conversion
* @param from The railtype we are converting from
@ -296,7 +312,7 @@ static inline Money RailConvertCost(RailType from, RailType to)
}
/* make the price the same as remove + build new type */
return RailBuildCost(to) + _price[PR_CLEAR_RAIL];
return RailBuildCost(to) + RailClearCost(from);
}
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);

View File

@ -510,7 +510,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
Track track = (Track)p2;
CommandCost cost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_RAIL] );
CommandCost cost(EXPENSES_CONSTRUCTION);
bool crossing = false;
if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR;
@ -533,6 +533,8 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
return CMD_ERROR;
}
cost.AddCost(RailClearCost(GetRailType(tile)));
if (flags & DC_EXEC) {
if (HasReservedTracks(tile, trackbit)) {
v = GetTrainForReservation(tile, track);
@ -557,6 +559,8 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
if ((present & trackbit) == 0) return CMD_ERROR;
if (present == (TRACK_BIT_X | TRACK_BIT_Y)) crossing = true;
cost.AddCost(RailClearCost(GetRailType(tile)));
/* Charge extra to remove signals on the track, if they are there */
if (HasSignalOnTrack(tile, track))
cost.AddCost(DoCommand(tile, track, 0, flags, CMD_REMOVE_SIGNALS));

View File

@ -617,6 +617,8 @@ static const RailBuildingGUIButtonData _rail_build_button_data[] = {
* @param clicked_widget Widget clicked in the toolbar
*/
struct BuildRailToolbarWindow : Window {
RailType railtype;
BuildRailToolbarWindow(const WindowDesc *desc, WindowNumber window_number, RailType railtype) : Window()
{
this->InitNested(desc);
@ -636,10 +638,11 @@ struct BuildRailToolbarWindow : Window {
*/
void SetupRailToolbar(RailType railtype)
{
this->railtype = railtype;
const RailtypeInfo *rti = GetRailTypeInfo(railtype);
assert(railtype < RAILTYPE_END);
this->GetWidget<NWidgetCore>(RTW_CAPTION)->widget_data = rti->strings.toolbar_caption;
this->GetWidget<NWidgetCore>(RTW_CAPTION)->widget_data = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
this->GetWidget<NWidgetCore>(RTW_BUILD_NS)->widget_data = rti->gui_sprites.build_ns_rail;
this->GetWidget<NWidgetCore>(RTW_BUILD_X)->widget_data = rti->gui_sprites.build_x_rail;
this->GetWidget<NWidgetCore>(RTW_BUILD_EW)->widget_data = rti->gui_sprites.build_ew_rail;
@ -689,6 +692,15 @@ struct BuildRailToolbarWindow : Window {
}
}
virtual void SetStringParameters(int widget) const
{
if (widget == RTW_CAPTION) {
const RailtypeInfo *rti = GetRailTypeInfo(this->railtype);
SetDParam(0, rti->strings.toolbar_caption);
SetDParam(1, rti->max_speed);
}
}
virtual void OnPaint()
{
this->DrawWidgets();

View File

@ -583,7 +583,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
default: {
do_clear:;
CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
CommandCost ret = DoCommand(tile, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
cost.AddCost(ret);
tile_cleared = true;
@ -632,6 +632,10 @@ do_clear:;
}
if (flags & DC_EXEC) {
/* CmdBuildLongRoad calls us directly with DC_EXEC, so we may only clear the tile after all
* fail/success tests have been done. */
if (tile_cleared) DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
switch (GetTileType(tile)) {
case MP_ROAD: {
RoadTileType rtt = GetRoadTileType(tile);

View File

@ -40,7 +40,7 @@ void UpdateHousesAndTowns()
if (!IsTileType(t, MP_HOUSE)) continue;
house_id = GetHouseType(t);
house_id = GetCleanHouseType(t);
if (!HouseSpec::Get(house_id)->enabled && house_id >= NEW_HOUSE_OFFSET) {
/* The specs for this type of house are not available any more, so
* replace it with the substitute original house type. */

View File

@ -649,7 +649,12 @@ static void ToolbarBuildRailClick(Window *w)
const RailtypeInfo *rti = GetRailTypeInfo(rt);
/* Skip rail type if it has no label */
if (rti->label == 0) continue;
list->push_back(new DropDownListStringItem(rti->strings.menu_text, rt, !HasBit(c->avail_railtypes, rt)));
StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
DropDownListParamStringItem *item = new DropDownListParamStringItem(str, rt, !HasBit(c->avail_railtypes, rt));
item->SetParam(0, rti->strings.menu_text);
item->SetParam(1, rti->max_speed);
list->push_back(item);
}
ShowDropDownList(w, list, _last_built_railtype, TBN_RAILS, 140, true, true);
SndPlayFx(SND_15_BEEP);