1
0
Fork 0

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

- Fix: One could not level the whole map anymore at once (r19392)
- Fix: Only show the 'No AIs available' error message when explicitly changing the number of AI opponents [FS3676] (r19389)
- Fix: [NoAI] When reloading a savegame, an AI failing to compile could trigger (trying) to read the not yet loaded information of another AI via the AI Debug window and its "open with the most recently used AI" feature [FS#3666] (r19388)
- Fix: Close all orders windows when switching companies [FS#3671] (r19387)
- Fix: [IPv6] Netmask calculations were wrong if cidr >= 32 [FS#3684] (r19385)
- Fix: Overbuilding bridges, rail stations did not properly update PBS reservation [FS#3680] (r19384, r19383)
release/1.0
rubidium 2010-03-12 21:12:35 +00:00
parent 4aef9b3247
commit 7c127b2760
13 changed files with 68 additions and 31 deletions

View File

@ -1016,3 +1016,11 @@ void ShowAIDebugWindow(CompanyID show_company)
ShowErrorMessage(STR_ERROR_AI_DEBUG_SERVER_ONLY, INVALID_STRING_ID, 0, 0);
}
}
/**
* Reset the AI windows to their initial state.
*/
void InitializeAIGui()
{
AIDebugWindow::ai_debug_company = INVALID_COMPANY;
}

View File

@ -41,6 +41,7 @@ void InitializeRailGui();
void InitializeRoadGui();
void InitializeAirportGui();
void InitializeDockGui();
void InitializeAIGui();
void InitializeIndustries();
void InitializeTowns();
void InitializeSubsidies();
@ -92,6 +93,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
InitializeRoadGui();
InitializeAirportGui();
InitializeDockGui();
InitializeAIGui();
InitializeTowns();
InitializeSubsidies();
InitializeTrees();

View File

@ -161,7 +161,7 @@ bool NetworkAddress::IsInNetmask(char *netmask)
while (cidr > 0) {
uint32 msk = cidr >= 32 ? (uint32)-1 : htonl(-(1 << (32 - cidr)));
if ((*mask & msk) != (*ip & msk)) return false;
if ((*mask++ & msk) != (*ip++ & msk)) return false;
cidr -= 32;
}

View File

@ -1350,7 +1350,7 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
static const WindowDesc _orders_train_desc(
WDP_AUTO, 384, 100,
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
0,
WDF_CONSTRUCTION,
_nested_orders_train_widgets, lengthof(_nested_orders_train_widgets)
);
@ -1415,7 +1415,7 @@ static const NWidgetPart _nested_orders_widgets[] = {
static const WindowDesc _orders_desc(
WDP_AUTO, 384, 100,
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
0,
WDF_CONSTRUCTION,
_nested_orders_widgets, lengthof(_nested_orders_widgets)
);

View File

@ -18,8 +18,8 @@
static const SaveLoad _industry_desc[] = {
SLE_CONDVAR(Industry, location.tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Industry, location.tile, SLE_UINT32, 6, SL_MAX_VERSION),
SLE_VAR(Industry, location.w, SLE_UINT8),
SLE_VAR(Industry, location.h, SLE_UINT8),
SLE_VAR(Industry, location.w, SLE_FILE_U8 | SLE_VAR_U16),
SLE_VAR(Industry, location.h, SLE_FILE_U8 | SLE_VAR_U16),
SLE_REF(Industry, town, REF_TOWN),
SLE_CONDNULL( 2, 0, 60), ///< used to be industry's produced_cargo
SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 2, 78, SL_MAX_VERSION),

View File

@ -714,7 +714,7 @@ static const OldChunks station_chunk[] = {
OCL_SVAR( OC_TILE, Station, train_station.tile ),
OCL_SVAR( OC_TILE, Station, airport_tile ),
OCL_SVAR( OC_TILE, Station, dock_tile ),
OCL_SVAR( OC_UINT8, Station, train_station.w ),
OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Station, train_station.w ),
OCL_NULL( 1 ), ///< sort-index, no longer in use
OCL_NULL( 2 ), ///< sign-width, no longer in use
@ -780,8 +780,8 @@ static bool LoadOldStation(LoadgameState *ls, int num)
static const OldChunks industry_chunk[] = {
OCL_SVAR( OC_TILE, Industry, location.tile ),
OCL_VAR ( OC_UINT32, 1, &_old_town_index ),
OCL_SVAR( OC_UINT8, Industry, location.w ),
OCL_SVAR( OC_UINT8, Industry, location.h ),
OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Industry, location.w ),
OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Industry, location.h ),
OCL_NULL( 2 ), ///< used to be industry's produced_cargo
OCL_SVAR( OC_TTD | OC_UINT16, Industry, produced_cargo_waiting[0] ),

View File

@ -156,8 +156,8 @@ static const SaveLoad _old_station_desc[] = {
SLE_CONDVAR(Station, dock_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Station, dock_tile, SLE_UINT32, 6, SL_MAX_VERSION),
SLE_REF(Station, town, REF_TOWN),
SLE_VAR(Station, train_station.w, SLE_UINT8),
SLE_CONDVAR(Station, train_station.h, SLE_UINT8, 2, SL_MAX_VERSION),
SLE_VAR(Station, train_station.w, SLE_FILE_U8 | SLE_VAR_U16),
SLE_CONDVAR(Station, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, 2, SL_MAX_VERSION),
SLE_CONDNULL(1, 0, 3), ///< alpha_order
@ -325,8 +325,8 @@ static const SaveLoad _station_desc[] = {
SLE_ST_INCLUDE(),
SLE_VAR(Station, train_station.tile, SLE_UINT32),
SLE_VAR(Station, train_station.w, SLE_UINT8),
SLE_VAR(Station, train_station.h, SLE_UINT8),
SLE_VAR(Station, train_station.w, SLE_FILE_U8 | SLE_VAR_U16),
SLE_VAR(Station, train_station.h, SLE_FILE_U8 | SLE_VAR_U16),
SLE_REF(Station, bus_stops, REF_ROADSTOPS),
SLE_REF(Station, truck_stops, REF_ROADSTOPS),
@ -354,8 +354,8 @@ static const SaveLoad _waypoint_desc[] = {
SLE_VAR(Waypoint, town_cn, SLE_UINT16),
SLE_CONDVAR(Waypoint, train_station.tile, SLE_UINT32, 124, SL_MAX_VERSION),
SLE_CONDVAR(Waypoint, train_station.w, SLE_UINT8, 124, SL_MAX_VERSION),
SLE_CONDVAR(Waypoint, train_station.h, SLE_UINT8, 124, SL_MAX_VERSION),
SLE_CONDVAR(Waypoint, train_station.w, SLE_FILE_U8 | SLE_VAR_U16, 124, SL_MAX_VERSION),
SLE_CONDVAR(Waypoint, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, 124, SL_MAX_VERSION),
SLE_END()
};

View File

@ -865,14 +865,6 @@ static bool DifficultyChange(int32)
_settings_game.difficulty.diff_level = 3;
}
if (((_game_mode == GM_MENU) ? _settings_newgame.difficulty : _settings_game.difficulty).max_no_competitors != 0 &&
#ifdef ENABLE_AI
AI::GetInfoList()->size() == 0 &&
#endif /* ENABLE_AI */
(!_networking || _network_server)) {
ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, 0, 0, true);
}
/* If we are a network-client, update the difficult setting (if it is open).
* Use this instead of just dirtying the window because we need to load in
* the new difficulty settings */
@ -895,6 +887,19 @@ static bool DifficultyNoiseChange(int32 i)
return DifficultyChange(i);
}
static bool MaxNoAIsChange(int32 i)
{
if (((_game_mode == GM_MENU) ? _settings_newgame.difficulty : _settings_game.difficulty).max_no_competitors != 0 &&
#ifdef ENABLE_AI
AI::GetInfoList()->size() == 0 &&
#endif /* ENABLE_AI */
(!_networking || _network_server)) {
ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, 0, 0, true);
}
return DifficultyChange(i);
}
/**
* Check whether the road side may be changed.
* @param p1 unused

View File

@ -672,7 +672,7 @@ CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags);
* @param rt The rail type to check for (overbuilding rail stations over rail)
* @return the cost in case of success, or an error code if it failed.
*/
CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear = true, RailType rt = INVALID_RAILTYPE)
CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear = true, RailType rt = INVALID_RAILTYPE, SmallVector<Train *, 4> *affected_vehicles = NULL)
{
CommandCost cost(EXPENSES_CONSTRUCTION);
int allowed_z = -1;
@ -749,6 +749,13 @@ CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag fla
Track expected_track = HasBit(invalid_dirs, DIAGDIR_NE) ? TRACK_X : TRACK_Y;
if (tracks == TRACK_BIT_NONE && track == expected_track) {
/* Check for trains having a reservation for this tile. */
if (HasBit(GetRailReservationTrackBits(tile_cur), track)) {
Train *v = GetTrainForReservation(tile_cur, track);
if (v != NULL && affected_vehicles != NULL) {
*(*affected_vehicles).Append() = v;
}
}
CommandCost ret = DoCommand(tile_cur, 0, track, flags, CMD_REMOVE_SINGLE_RAIL);
if (ret.Failed()) return ret;
cost.AddCost(ret);
@ -1007,8 +1014,9 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
/* Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) */
StationID est = INVALID_STATION;
SmallVector<Train *, 4> affected_vehicles;
/* Clear the land below the station. */
CommandCost cost = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _settings_game.station.nonuniform_stations ? &est : NULL, true, rt);
CommandCost cost = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _settings_game.station.nonuniform_stations ? &est : NULL, true, rt, &affected_vehicles);
if (cost.Failed()) return cost;
/* Add construction expenses. */
cost.AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
@ -1095,7 +1103,6 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
numtracks_orig = numtracks;
SmallVector<Train*, 4> affected_vehicles;
do {
TileIndex tile = tile_org;
int w = plat_len;

View File

@ -29,6 +29,7 @@ static bool TownFoundingChanged(int32 p1);
static bool DifficultyReset(int32 level);
static bool DifficultyChange(int32);
static bool DifficultyNoiseChange(int32 i);
static bool MaxNoAIsChange(int32 i);
static bool CheckRoadSide(int p1);
static int32 ConvertLandscape(const char *value);
static bool CheckFreeformEdges(int32 p1);
@ -334,7 +335,7 @@ const SettingDesc _settings[] = {
/***************************************************************************/
/* Saved settings variables. */
/* Do not ADD or REMOVE something in this "difficulty.XXX" table or before it. It breaks savegame compatability. */
SDT_CONDVAR(GameSettings, difficulty.max_no_competitors, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0,0,MAX_COMPANIES-1,1,STR_NULL, DifficultyChange),
SDT_CONDVAR(GameSettings, difficulty.max_no_competitors, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0,0,MAX_COMPANIES-1,1,STR_NULL, MaxNoAIsChange),
SDT_CONDNULL( 1, 97, 109),
SDT_CONDVAR(GameSettings, difficulty.number_towns, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 0, 4, 1, STR_NUM_VERY_LOW, DifficultyChange),
SDT_CONDVAR(GameSettings, difficulty.number_industries, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 4, 0, 4, 1, STR_NONE, DifficultyChange),

View File

@ -17,8 +17,8 @@
/** Represents the covered area of e.g. a rail station */
struct TileArea {
TileIndex tile; ///< The base tile of the area
uint8 w; ///< The width of the area
uint8 h; ///< The height of the area
uint16 w; ///< The width of the area
uint16 h; ///< The height of the area
/** Just construct this tile area */
TileArea() {}

View File

@ -256,6 +256,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
uint z_end;
Slope tileh_start = GetTileSlope(tile_start, &z_start);
Slope tileh_end = GetTileSlope(tile_end, &z_end);
bool pbs_reservation = false;
CommandCost terraform_cost_north = CheckBridgeSlopeNorth(direction, &tileh_start, &z_start);
CommandCost terraform_cost_south = CheckBridgeSlopeSouth(direction, &tileh_end, &z_end);
@ -298,8 +299,19 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
cost.AddCost((bridge_len + 1) * _price[PR_CLEAR_BRIDGE]); // The cost of clearing the current bridge.
owner = GetTileOwner(tile_start);
/* Do not remove road types when upgrading a bridge */
roadtypes |= GetRoadTypes(tile_start);
switch (transport_type) {
case TRANSPORT_RAIL:
/* Keep the reservation, the path stays valid. */
pbs_reservation = HasTunnelBridgeReservation(tile_start);
break;
case TRANSPORT_ROAD:
/* Do not remove road types when upgrading a bridge */
roadtypes |= GetRoadTypes(tile_start);
break;
default: break;
}
} else {
/* Build a new bridge. */
@ -404,6 +416,8 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
case TRANSPORT_RAIL:
MakeRailBridgeRamp(tile_start, owner, bridge_type, dir, railtype);
MakeRailBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), railtype);
SetTunnelBridgeReservation(tile_start, pbs_reservation);
SetTunnelBridgeReservation(tile_end, pbs_reservation);
break;
case TRANSPORT_ROAD:

View File

@ -98,7 +98,7 @@ void UpdateCompanyHQ(Company *c, uint score)
MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
}
extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear = true, RailType rt = INVALID_RAILTYPE);
extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear = true, RailType rt = INVALID_RAILTYPE, SmallVector<Train *, 4> *affected_trains = NULL);
/** Build or relocate the HQ. This depends if the HQ is already built or not
* @param tile tile where the HQ will be built or relocated to