1
0
Fork 0

(svn r22838) [1.1] -Backport from trunk:

- Fix: Display the size of the leveled platform in the measurement tooltip of terraforming operations [FS#4708] (r22740, r22739)
- Fix: Setting company passwords via the GUI on servers (including starting a company with the default password) failed, so no client could join that company [FS#4722] (r22738)
- Fix: [NewGRF] The construction stage sprites were incorrectly selected in cases other than 1 or 4 sprites per set (r22731)
- Fix: [NoAI] AITile::GetCargoAcceptance, AITile::GetCargoProduction and AIRail::BuildNewGRFRailStation did not check the cargo argument for validity (r22726)
release/1.1
rubidium 2011-08-25 13:24:32 +00:00
parent c5387508eb
commit 85ee1737e4
11 changed files with 36 additions and 11 deletions

View File

@ -14,6 +14,7 @@
#include "ai_map.hpp" #include "ai_map.hpp"
#include "ai_station.hpp" #include "ai_station.hpp"
#include "ai_industrytype.hpp" #include "ai_industrytype.hpp"
#include "ai_cargo.hpp"
#include "../../debug.h" #include "../../debug.h"
#include "../../station_base.h" #include "../../station_base.h"
#include "../../company_func.h" #include "../../company_func.h"
@ -170,6 +171,7 @@
EnforcePrecondition(false, platform_length > 0 && platform_length <= 0xFF); EnforcePrecondition(false, platform_length > 0 && platform_length <= 0xFF);
EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType())); EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
EnforcePrecondition(false, station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id)); EnforcePrecondition(false, station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id));
EnforcePrecondition(false, AICargo::IsValidCargo(cargo_id));
EnforcePrecondition(false, source_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(source_industry)); EnforcePrecondition(false, source_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(source_industry));
EnforcePrecondition(false, goal_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(goal_industry)); EnforcePrecondition(false, goal_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(goal_industry));

View File

@ -279,6 +279,7 @@ public:
* @pre num_platforms > 0 && num_platforms <= 255. * @pre num_platforms > 0 && num_platforms <= 255.
* @pre platform_length > 0 && platform_length <= 255. * @pre platform_length > 0 && platform_length <= 255.
* @pre station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id). * @pre station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id).
* @pre AICargo::IsValidCargo(cargo_type)
* @pre source_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(source_industry). * @pre source_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(source_industry).
* @pre goal_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(goal_industry). * @pre goal_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(goal_industry).
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY

View File

@ -13,6 +13,7 @@
#include "ai_tile.hpp" #include "ai_tile.hpp"
#include "ai_map.hpp" #include "ai_map.hpp"
#include "ai_town.hpp" #include "ai_town.hpp"
#include "ai_cargo.hpp"
#include "../../station_func.h" #include "../../station_func.h"
#include "../../company_func.h" #include "../../company_func.h"
#include "../../water_map.h" #include "../../water_map.h"
@ -192,7 +193,7 @@
/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius) /* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
{ {
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0) return -1; if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !AICargo::IsValidCargo(cargo_type)) return -1;
CargoArray acceptance = ::GetAcceptanceAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED); CargoArray acceptance = ::GetAcceptanceAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
return acceptance[cargo_type]; return acceptance[cargo_type];
@ -200,7 +201,7 @@
/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius) /* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
{ {
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0) return -1; if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !AICargo::IsValidCargo(cargo_type)) return -1;
CargoArray produced = ::GetProductionAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED); CargoArray produced = ::GetProductionAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
return produced[cargo_type]; return produced[cargo_type];

View File

@ -319,6 +319,7 @@ public:
* @param height The height of the station. * @param height The height of the station.
* @param radius The radius of the station. * @param radius The radius of the station.
* @pre AIMap::IsValidTile(tile). * @pre AIMap::IsValidTile(tile).
* @pre AICargo::IsValidCargo(cargo_type)
* @pre width > 0. * @pre width > 0.
* @pre height > 0. * @pre height > 0.
* @pre radius >= 0. * @pre radius >= 0.
@ -335,6 +336,7 @@ public:
* @param height The height of the station. * @param height The height of the station.
* @param radius The radius of the station. * @param radius The radius of the station.
* @pre AIMap::IsValidTile(tile). * @pre AIMap::IsValidTile(tile).
* @pre AICargo::IsValidCargo(cargo_type)
* @pre width > 0. * @pre width > 0.
* @pre height > 0. * @pre height > 0.
* @pre radius >= 0. * @pre radius >= 0.

View File

@ -1640,7 +1640,7 @@ DEF_CONSOLE_CMD(ConCompanyPassword)
return false; return false;
} }
password = NetworkChangeCompanyPassword(company_id, password, false); password = NetworkChangeCompanyPassword(company_id, password);
if (StrEmpty(password)) { if (StrEmpty(password)) {
IConsolePrintF(CC_WARNING, "Company password cleared"); IConsolePrintF(CC_WARNING, "Company password cleared");

View File

@ -156,12 +156,12 @@ byte NetworkSpectatorCount()
* @param password The unhashed password we like to set ('*' or '' resets the password) * @param password The unhashed password we like to set ('*' or '' resets the password)
* @return The password. * @return The password.
*/ */
const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password, bool already_hashed) const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password)
{ {
if (strcmp(password, "*") == 0) password = ""; if (strcmp(password, "*") == 0) password = "";
if (_network_server) { if (_network_server) {
NetworkServerSetCompanyPassword(company_id, password, already_hashed); NetworkServerSetCompanyPassword(company_id, password, false);
} else { } else {
NetworkClientSetCompanyPassword(password); NetworkClientSetCompanyPassword(password);
} }

View File

@ -36,7 +36,7 @@ extern StringList _network_ban_list;
byte NetworkSpectatorCount(); byte NetworkSpectatorCount();
void NetworkUpdateClientName(); void NetworkUpdateClientName();
bool NetworkCompanyHasClients(CompanyID company); bool NetworkCompanyHasClients(CompanyID company);
const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password, bool already_hashed = true); const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password);
void NetworkReboot(); void NetworkReboot();
void NetworkDisconnect(bool blocking = false, bool close_admins = true); void NetworkDisconnect(bool blocking = false, bool close_admins = true);
void NetworkGameLoop(); void NetworkGameLoop();

View File

@ -459,7 +459,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
/* Limit the building stage to the number of stages supplied. */ /* Limit the building stage to the number of stages supplied. */
const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group; const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group;
byte stage = GetHouseBuildingStage(ti->tile); byte stage = GetHouseBuildingStage(ti->tile);
stage = Clamp(stage - 4 + tlgroup->num_building_stages, 0, tlgroup->num_building_stages - 1); stage = tlgroup->GetConstructionStageOffset(stage);
DrawTileLayout(ti, tlgroup, stage, house_id); DrawTileLayout(ti, tlgroup, stage, house_id);
} }
} }

View File

@ -237,7 +237,7 @@ bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const Indus
/* Limit the building stage to the number of stages supplied. */ /* Limit the building stage to the number of stages supplied. */
const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group; const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group;
byte stage = GetIndustryConstructionStage(ti->tile); byte stage = GetIndustryConstructionStage(ti->tile);
stage = Clamp(stage - 4 + tlgroup->num_building_stages, 0, tlgroup->num_building_stages - 1); stage = tlgroup->GetConstructionStageOffset(stage);
IndustryDrawTileLayout(ti, tlgroup, i->random_colour, stage, gfx); IndustryDrawTileLayout(ti, tlgroup, i->random_colour, stage, gfx);
return true; return true;
} }

View File

@ -287,6 +287,25 @@ struct TileLayoutSpriteGroup : SpriteGroup {
byte num_building_stages; ///< Number of building stages to show for this house/industry tile byte num_building_stages; ///< Number of building stages to show for this house/industry tile
struct DrawTileSprites *dts; struct DrawTileSprites *dts;
/**
* Determines which sprite to use from a spriteset for a specific construction stage.
* @param construction_stage Construction stage 0 - 3.
* @return Sprite to use
*/
uint GetConstructionStageOffset(uint construction_stage) const
{
uint num_sprites = this->num_building_stages;
assert(num_sprites > 0);
if (num_sprites > 4) num_sprites = 4;
switch (construction_stage) {
case 0: return 0;
case 1: return num_sprites > 2 ? 1 : 0;
case 2: return num_sprites > 2 ? num_sprites - 2 : 0;
case 3: return num_sprites - 1;
default: NOT_REACHED();
}
}
}; };
struct IndustryProductionSpriteGroup : SpriteGroup { struct IndustryProductionSpriteGroup : SpriteGroup {

View File

@ -2778,11 +2778,11 @@ calc_heightdiff_single_direction:;
} }
} }
if (t0 != 1 || t1 != 1) { if (dx != 1 || dy != 1) {
int heightdiff = CalcHeightdiff(style, 0, t0, t1); int heightdiff = CalcHeightdiff(style, 0, t0, t1);
params[index++] = dx; params[index++] = dx - (style & HT_POINT ? 1 : 0);
params[index++] = dy; params[index++] = dy - (style & HT_POINT ? 1 : 0);
if (heightdiff != 0) params[index++] = heightdiff; if (heightdiff != 0) params[index++] = heightdiff;
} }