Merge branch 'master' into jgrpp

# Conflicts:
#	src/airport_gui.cpp
#	src/blitter/32bpp_anim_sse4.cpp
#	src/console_cmds.cpp
#	src/linkgraph/linkgraph_gui.cpp
#	src/newgrf_object.h
#	src/road_gui.cpp
#	src/widgets/road_widget.h
#	src/window.cpp
This commit is contained in:
Jonathan G Rennison
2022-10-16 20:14:13 +01:00
82 changed files with 778 additions and 341 deletions

View File

@@ -17,9 +17,14 @@
*
* This version is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li AICargo::GetWeight
* \li AIIndustryType::ResolveNewGRFID
* \li AIObjectType::ResolveNewGRFID
*
* Other changes:
* \li AIRoad::HasRoadType now correctly checks RoadType against RoadType
*
* \b 12.0
*
* API additions:

View File

@@ -17,9 +17,14 @@
*
* This version is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li GSCargo::GetWeight
* \li GSIndustryType::ResolveNewGRFID
* \li GSObjectType::ResolveNewGRFID
*
* Other changes:
* \li GSRoad::HasRoadType now correctly checks RoadType against RoadType
*
* \b 12.0
*
* API additions:

View File

@@ -81,3 +81,9 @@
if (!ScriptCargo::IsValidCargo(cargo_type)) return INVALID_DISTRIBUTION_TYPE;
return (ScriptCargo::DistributionType)_settings_game.linkgraph.GetDistributionType(cargo_type);
}
/* static */ int64 ScriptCargo::GetWeight(CargoID cargo_type, uint32 amount)
{
if (!IsValidCargo(cargo_type)) return -1;
return ::CargoSpec::Get(cargo_type)->weight * static_cast<int64>(amount) / 16;
}

View File

@@ -153,6 +153,16 @@ public:
* @return The cargo distribution type for the given cargo.
*/
static DistributionType GetDistributionType(CargoID cargo_type);
/**
* Get the weight in tonnes for the given amount of
* cargo for the specified type.
* @param cargo_type The cargo to check on.
* @param amount The quantity of cargo.
* @pre ScriptCargo::IsValidCargo(cargo_type).
* @return The weight in tonnes for that quantity of cargo.
*/
static int64 GetWeight(CargoID cargo_type, uint32 amount);
};
#endif /* SCRIPT_CARGO_HPP */

View File

@@ -95,7 +95,7 @@
{
if (!ScriptMap::IsValidTile(tile)) return false;
if (!IsRoadTypeAvailable(road_type)) return false;
return ::GetAnyRoadBits(tile, ::GetRoadTramType((::RoadType)road_type), false) != ROAD_NONE;
return ::MayHaveRoad(tile) && HasBit(::GetPresentRoadTypes(tile), (::RoadType)road_type);
}
/* static */ bool ScriptRoad::HasRoadTramType(TileIndex tile, RoadTramTypes road_tram_type)

View File

@@ -145,15 +145,16 @@ void ScriptScanner::RegisterScript(ScriptInfo *info)
}
}
char *ScriptScanner::GetConsoleList(char *p, const char *last, bool newest_only) const
std::string ScriptScanner::GetConsoleList(bool newest_only) const
{
p += seprintf(p, last, "List of %s:\n", this->GetScannerName());
std::string p;
p += stdstr_fmt("List of %s:\n", this->GetScannerName());
const ScriptInfoList &list = newest_only ? this->info_single_list : this->info_list;
for (const auto &item : list) {
ScriptInfo *i = item.second;
p += seprintf(p, last, "%10s (v%d): %s\n", i->GetName(), i->GetVersion(), i->GetDescription());
p += stdstr_fmt("%10s (v%d): %s\n", i->GetName(), i->GetVersion(), i->GetDescription());
}
p += seprintf(p, last, "\n");
p += "\n";
return p;
}

View File

@@ -57,7 +57,7 @@ public:
/**
* Get the list of registered scripts to print on the console.
*/
char *GetConsoleList(char *p, const char *last, bool newest_only) const;
std::string GetConsoleList(bool newest_only) const;
/**
* Check whether we have a script with the exact characteristics as ci.