mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-31 03:12:41 +00:00
(svn r9582) [0.5] -Backport from trunk (r9425, r9437, r9455, r9519):
- Fix: housekeeping in convert rail functions (r9425) - Fix: dedicated server crashed when the y part of the resolution was less than 10 (r9437) - Fix: values of diff_custom and snow_line in .cfg weren't checked properly (r9455) - Fix: free the malloc'd variable, not the pointer to that variable (r9519)
This commit is contained in:
parent
a0688e8d85
commit
c8c8667dc8
@ -144,10 +144,10 @@ static FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
||||
|
||||
|
||||
folder_error:
|
||||
#if defined(UNICODE)
|
||||
free(font_path);
|
||||
#endif
|
||||
registry_no_font_found:
|
||||
#if defined(UNICODE)
|
||||
free(font_namep);
|
||||
#endif
|
||||
RegCloseKey(hKey);
|
||||
return err;
|
||||
}
|
||||
|
15
rail_cmd.c
15
rail_cmd.c
@ -874,15 +874,24 @@ int32 CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
typedef int32 DoConvertRailProc(TileIndex tile, RailType totype, bool exec);
|
||||
|
||||
/**
|
||||
* Switches the rail type.
|
||||
* Railtypes are stored on a per-tile basis, not on a per-track basis, so
|
||||
* all the tracks in the given tile will be converted.
|
||||
* @param tile The tile on which the railtype is to be convert.
|
||||
* @param totype The railtype we want to convert to
|
||||
* @param exec Switches between test and execute mode
|
||||
* @return The cost and state of the operation
|
||||
* @retval CMD_ERROR An error occured during the operation.
|
||||
*/
|
||||
static int32 DoConvertRail(TileIndex tile, RailType totype, bool exec)
|
||||
{
|
||||
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
||||
|
||||
if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
|
||||
|
||||
// tile is already of requested type?
|
||||
if (GetRailType(tile) == totype) return CMD_ERROR;
|
||||
|
||||
if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
|
||||
|
||||
// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
|
||||
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
|
||||
|
||||
|
10
road_cmd.c
10
road_cmd.c
@ -422,6 +422,14 @@ do_clear:;
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches the rail type on a level crossing.
|
||||
* @param tile The tile on which the railtype is to be convert.
|
||||
* @param totype The railtype we want to convert to
|
||||
* @param exec Switches between test and execute mode
|
||||
* @return The cost and state of the operation
|
||||
* @retval CMD_ERROR An error occured during the operation.
|
||||
*/
|
||||
int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
|
||||
{
|
||||
// not a railroad crossing?
|
||||
@ -441,7 +449,7 @@ int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
|
||||
YapfNotifyTrackLayoutChange(tile, FIND_FIRST_BIT(GetCrossingRailBits(tile)));
|
||||
}
|
||||
|
||||
return _price.build_rail >> 1;
|
||||
return _price.build_rail / 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1241,12 +1241,12 @@ static const SettingDesc _gameopt_settings[] = {
|
||||
* and why not byte for example? */
|
||||
SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, 0, 3),
|
||||
SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, 4, SL_MAX_VERSION),
|
||||
SDT_VAR(GameOptions, diff_level,SLE_UINT8, 0, 0, 9, 0, 9, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameOptions, diff_level,SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
|
||||
SDT_OMANY(GameOptions, currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL),
|
||||
SDT_OMANY(GameOptions, units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL),
|
||||
SDT_OMANY(GameOptions, town_name, SLE_UINT8, 0, 0, 0, 20, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL),
|
||||
SDT_OMANY(GameOptions, landscape, SLE_UINT8, 0, 0, 0, 3, "normal|hilly|desert|candy", STR_NULL, NULL),
|
||||
SDT_VAR(GameOptions, snow_line, SLE_UINT8, 0, 0, 1, 0, 56, 0, STR_NULL, NULL),
|
||||
SDT_VAR(GameOptions, snow_line, SLE_UINT8, 0, 0, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
|
||||
SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8, 0, 22, N, 0, 0, 0, "", STR_NULL, NULL),
|
||||
SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8,23, SL_MAX_VERSION, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL),
|
||||
SDT_OMANY(GameOptions, road_side, SLE_UINT8, 0, 0, 1, 1, "left|right", STR_NULL, NULL),
|
||||
@ -1650,6 +1650,8 @@ static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescP
|
||||
#endif /* ENABLE_NETWORK */
|
||||
}
|
||||
|
||||
extern void CheckDifficultyLevels(void);
|
||||
|
||||
/** Load the values from the configuration files */
|
||||
void LoadFromConfig(void)
|
||||
{
|
||||
@ -1659,6 +1661,7 @@ void LoadFromConfig(void)
|
||||
_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
|
||||
_grfconfig_static = GRFLoadConfig(ini, "newgrf-static", true);
|
||||
_news_display_opt = NewsDisplayLoadConfig(ini, "news_display");
|
||||
CheckDifficultyLevels();
|
||||
ini_free(ini);
|
||||
}
|
||||
|
||||
|
@ -368,6 +368,24 @@ void SetDifficultyLevel(int mode, GameOptions *gm_opt)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the difficulty levels read from the configuration and
|
||||
* forces them to be correct when invalid.
|
||||
*/
|
||||
void CheckDifficultyLevels(void)
|
||||
{
|
||||
if (_opt_newgame.diff_level != 3) {
|
||||
SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame);
|
||||
} else {
|
||||
uint i;
|
||||
for (i = 0; i < GAME_DIFFICULTY_NUM; i++) {
|
||||
int *diff = ((int*)&_opt_newgame.diff) + i;
|
||||
*diff = clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
|
||||
*diff -= *diff % _game_setting_info[i].step;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern void StartupEconomy(void);
|
||||
|
||||
enum {
|
||||
|
@ -1337,6 +1337,14 @@ static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches the rail type at a railway station tile.
|
||||
* @param tile The tile on which the railtype is to be convert.
|
||||
* @param totype The railtype we want to convert to
|
||||
* @param exec Switches between test and execute mode
|
||||
* @return The cost and state of the operation
|
||||
* @retval CMD_ERROR An error occured during the operation.
|
||||
*/
|
||||
int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
|
||||
{
|
||||
const Station* st = GetStationByTile(tile);
|
||||
@ -1357,7 +1365,7 @@ int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
|
||||
YapfNotifyTrackLayoutChange(tile, GetRailStationTrack(tile));
|
||||
}
|
||||
|
||||
return _price.build_rail >> 1;
|
||||
return _price.build_rail / 2;
|
||||
}
|
||||
|
||||
/** Heavy wizardry used to add a roadstop to a station.
|
||||
|
@ -152,6 +152,7 @@ void UndrawTextMessage(void)
|
||||
if (x + width >= _screen.width) {
|
||||
width = _screen.width - x;
|
||||
}
|
||||
if (width <= 0 || height <= 0) return;
|
||||
|
||||
_textmessage_visible = false;
|
||||
// Put our 'shot' back to the screen
|
||||
@ -219,6 +220,8 @@ void DrawTextMessage(void)
|
||||
if (x + width >= _screen.width) {
|
||||
width = _screen.width - x;
|
||||
}
|
||||
if (width <= 0 || height <= 0) return;
|
||||
|
||||
// Make a copy of the screen as it is before painting (for undraw)
|
||||
memcpy_pitch(
|
||||
_textmessage_backup,
|
||||
|
@ -764,6 +764,16 @@ static int32 ClearTile_TunnelBridge(TileIndex tile, byte flags)
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches the rail type for a tunnel or a bridgehead. As the railtype
|
||||
* on the bridge are determined by the one of the bridgehead, this
|
||||
* functions converts the railtype on the entire bridge.
|
||||
* @param tile The tile on which the railtype is to be convert.
|
||||
* @param totype The railtype we want to convert to
|
||||
* @param exec Switches between test and execute mode
|
||||
* @return The cost and state of the operation
|
||||
* @retval CMD_ERROR An error occured during the operation.
|
||||
*/
|
||||
int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||
{
|
||||
TileIndex endtile;
|
||||
@ -792,7 +802,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
YapfNotifyTrackLayoutChange(endtile, track);
|
||||
}
|
||||
return (length + 1) * (_price.build_rail >> 1);
|
||||
return (length + 1) * (_price.build_rail / 2);
|
||||
} else if (IsBridge(tile) &&
|
||||
IsBridgeMiddle(tile) &&
|
||||
IsTransportUnderBridge(tile) &&
|
||||
@ -809,7 +819,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||
|
||||
YapfNotifyTrackLayoutChange(tile, GetRailUnderBridge(tile));
|
||||
}
|
||||
return _price.build_rail >> 1;
|
||||
return _price.build_rail / 2;
|
||||
} else if (IsBridge(tile) && IsBridgeRamp(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
|
||||
TileIndexDiff delta;
|
||||
int32 cost;
|
||||
@ -837,14 +847,14 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
YapfNotifyTrackLayoutChange(endtile, track);
|
||||
}
|
||||
cost = 2 * (_price.build_rail >> 1);
|
||||
cost = 2 * (_price.build_rail / 2);
|
||||
delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
|
||||
for (tile += delta; tile != endtile; tile += delta) {
|
||||
if (exec) {
|
||||
SetRailTypeOnBridge(tile, totype);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
cost += _price.build_rail >> 1;
|
||||
cost += _price.build_rail / 2;
|
||||
}
|
||||
|
||||
return cost;
|
||||
|
Loading…
Reference in New Issue
Block a user