mirror of https://github.com/OpenTTD/OpenTTD
(svn r16803) [0.7] -Backport from trunk:
- Add: [NoAI] AIVehicle::GetReliability to get the current reliability of vehicles (r16790) - Fix: The win32 and win64 binary packages would not get their readme converted to DOS line endings (r16769) - Fix: [NoAI] AITile::GetCargoProduction/Acceptance did not accept a radius of 0 anymore (r16767) - Fix: In the refit window the "Select cargo type to carry" line always showed the ship refit tooltip [FS#3018] (r16757)release/0.7
parent
893bccf4c8
commit
3edbb1a543
|
@ -19,7 +19,7 @@ BIN_DIR = "$(ROOT_DIR)/bin"
|
|||
SRC_DIR = "$(ROOT_DIR)/src"
|
||||
BUNDLE_DIR = "$(ROOT_DIR)/bundle"
|
||||
BUNDLES_DIR = "$(ROOT_DIR)/bundles"
|
||||
TTD = "openttd.exe"
|
||||
TTD = openttd.exe
|
||||
TARGET := $(shell echo $(PLATFORM) | sed "s@win64@x64@;s@win32@Win32@")
|
||||
|
||||
all:
|
||||
|
|
|
@ -561,6 +561,7 @@ struct AIDebugWindow : public Window {
|
|||
enum AIDebugWindowWidgets {
|
||||
AID_WIDGET_CLOSEBOX = 0,
|
||||
AID_WIDGET_CAPTION,
|
||||
AID_WIDGET_STICKY,
|
||||
AID_WIDGET_VIEW,
|
||||
AID_WIDGET_NAME_TEXT,
|
||||
AID_WIDGET_RELOAD_TOGGLE,
|
||||
|
@ -768,6 +769,7 @@ CompanyID AIDebugWindow::ai_debug_company = INVALID_COMPANY;
|
|||
static const Widget _ai_debug_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // AID_WIDGET_CLOSEBOX
|
||||
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 298, 0, 13, STR_AI_DEBUG, STR_018C_WINDOW_TITLE_DRAG_THIS}, // AID_WIDGET_CAPTION
|
||||
{ WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 287, 298, 0, 13, 0x0, STR_STICKY_BUTTON }, // AID_WIDGET_STICKY
|
||||
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 0, 298, 14, 40, 0x0, STR_NULL}, // AID_WIDGET_VIEW
|
||||
|
||||
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 0, 149, 41, 60, 0x0, STR_AI_DEBUG_NAME_TIP}, // AID_WIDGET_NAME_TEXT
|
||||
|
@ -805,7 +807,7 @@ static const Widget _ai_debug_widgets[] = {
|
|||
static const WindowDesc _ai_debug_desc(
|
||||
WDP_AUTO, WDP_AUTO, 299, 241, 299, 241,
|
||||
WC_AI_DEBUG, WC_NONE,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
|
||||
_ai_debug_widgets
|
||||
);
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
|
||||
/* 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) return -1;
|
||||
|
||||
AcceptedCargo accepts;
|
||||
::GetAcceptanceAroundTiles(accepts, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
|
||||
|
@ -186,7 +186,7 @@
|
|||
|
||||
/* 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) return -1;
|
||||
|
||||
AcceptedCargo produced;
|
||||
::GetProductionAroundTiles(produced, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
|
||||
|
|
|
@ -305,7 +305,7 @@ public:
|
|||
* @pre AIMap::IsValidTile(tile).
|
||||
* @pre width > 0.
|
||||
* @pre height > 0.
|
||||
* @pre radius > 0.
|
||||
* @pre radius >= 0.
|
||||
* @return Value below 8 means no acceptance; the more the better.
|
||||
*/
|
||||
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
|
||||
|
@ -322,7 +322,7 @@ public:
|
|||
* @pre AIMap::IsValidTile(tile).
|
||||
* @pre width > 0.
|
||||
* @pre height > 0.
|
||||
* @pre radius > 0.
|
||||
* @pre radius >= 0.
|
||||
* @return The tiles that produce this cargo within radius of the tile.
|
||||
* @note Town(houses) are not included in the value.
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace SQConvert {
|
|||
void SQAITileList_IndustryAccepting_Register(Squirrel *engine) {
|
||||
DefSQClass <AITileList_IndustryAccepting> SQAITileList_IndustryAccepting("AITileList_IndustryAccepting");
|
||||
SQAITileList_IndustryAccepting.PreRegister(engine, "AITileList");
|
||||
SQAITileList_IndustryAccepting.AddConstructor<void (AITileList_IndustryAccepting::*)(IndustryID industry_id, uint radius), 3>(engine, "xii");
|
||||
SQAITileList_IndustryAccepting.AddConstructor<void (AITileList_IndustryAccepting::*)(IndustryID industry_id, int radius), 3>(engine, "xii");
|
||||
|
||||
SQAITileList_IndustryAccepting.PostRegister(engine);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace SQConvert {
|
|||
void SQAITileList_IndustryProducing_Register(Squirrel *engine) {
|
||||
DefSQClass <AITileList_IndustryProducing> SQAITileList_IndustryProducing("AITileList_IndustryProducing");
|
||||
SQAITileList_IndustryProducing.PreRegister(engine, "AITileList");
|
||||
SQAITileList_IndustryProducing.AddConstructor<void (AITileList_IndustryProducing::*)(IndustryID industry_id, uint radius), 3>(engine, "xii");
|
||||
SQAITileList_IndustryProducing.AddConstructor<void (AITileList_IndustryProducing::*)(IndustryID industry_id, int radius), 3>(engine, "xii");
|
||||
|
||||
SQAITileList_IndustryProducing.PostRegister(engine);
|
||||
}
|
||||
|
|
|
@ -425,3 +425,11 @@
|
|||
Vehicle *v = ::GetVehicle(vehicle_id);
|
||||
return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
|
||||
}
|
||||
|
||||
/* static */ int AIVehicle::GetReliability(VehicleID vehicle_id)
|
||||
{
|
||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||
|
||||
const Vehicle *v = ::GetVehicle(vehicle_id);
|
||||
return v->reliability * 100 >> 16;
|
||||
}
|
||||
|
|
|
@ -525,6 +525,14 @@ public:
|
|||
*/
|
||||
static bool HasSharedOrders(VehicleID vehicle_id);
|
||||
|
||||
/**
|
||||
* Get the current reliability of a vehicle.
|
||||
* @param vehicle_id The vehicle to check.
|
||||
* @pre IsValidVehicle(vehicle_id).
|
||||
* @return The current reliability (0-100%).
|
||||
*/
|
||||
static int GetReliability(VehicleID vehicle_id);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Internal function used by SellWagon(Chain).
|
||||
|
|
|
@ -140,6 +140,7 @@ void SQAIVehicle_Register(Squirrel *engine) {
|
|||
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetGroupID, "GetGroupID", 2, ".i");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsArticulated, "IsArticulated", 2, ".i");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::HasSharedOrders, "HasSharedOrders", 2, ".i");
|
||||
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetReliability, "GetReliability", 2, ".i");
|
||||
|
||||
SQAIVehicle.PostRegister(engine);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
|
||||
# $Id$
|
||||
|
||||
# We really need gawk for this!
|
||||
AWK=gawk
|
||||
|
||||
${AWK} --version > /dev/null 2> /dev/null
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "This script needs gawk to run properly"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# This must be called from within the src/ai/api directory.
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
|
@ -10,7 +19,7 @@ if [ -z "$1" ]; then
|
|||
# these files should not be changed by this script
|
||||
"ai_controller.hpp" | "ai_object.hpp" | "ai_types.hpp" ) continue;
|
||||
esac
|
||||
awk -f squirrel_export.awk ${f} > ${f}.tmp
|
||||
${AWK} -f squirrel_export.awk ${f} > ${f}.tmp
|
||||
if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' -b ${f}.tmp ${f}.sq 2> /dev/null || echo boo`" ]; then
|
||||
mv ${f}.tmp ${f}.sq
|
||||
echo "Updated: ${f}.sq"
|
||||
|
@ -22,7 +31,7 @@ if [ -z "$1" ]; then
|
|||
fi
|
||||
done
|
||||
else
|
||||
awk -f squirrel_export.awk $1 > $1.tmp
|
||||
${AWK} -f squirrel_export.awk $1 > $1.tmp
|
||||
if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' -b $1.sq $1.tmp 2> /dev/null || echo boo`" ]; then
|
||||
mv $1.tmp $1.sq
|
||||
echo "Updated: $1.sq"
|
||||
|
@ -84,7 +93,7 @@ echo "
|
|||
{ print \$0; }
|
||||
" > ${f}.awk
|
||||
|
||||
awk -f ${f}.awk ${f} > ${f}.tmp
|
||||
${AWK} -f ${f}.awk ${f} > ${f}.tmp
|
||||
|
||||
if ! [ -f "${f}" ] || [ -n "`diff -I '$Id' -b ${f} ${f}.tmp 2> /dev/null || echo boo`" ]; then
|
||||
mv ${f}.tmp ${f}
|
||||
|
|
|
@ -287,24 +287,28 @@ struct RefitWindow : public Window {
|
|||
this->widget[3].tooltips = STR_RAIL_SELECT_TYPE_OF_CARGO_FOR;
|
||||
this->widget[6].data = STR_RAIL_REFIT_VEHICLE;
|
||||
this->widget[6].tooltips = STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED;
|
||||
this->widget[2].tooltips = STR_RAIL_SELECT_TYPE_OF_CARGO_FOR;
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
this->widget[3].tooltips = STR_ROAD_SELECT_TYPE_OF_CARGO_FOR;
|
||||
this->widget[6].data = STR_REFIT_ROAD_VEHICLE;
|
||||
this->widget[6].tooltips = STR_REFIT_ROAD_VEHICLE_TO_CARRY_HIGHLIGHTED;
|
||||
this->widget[2].tooltips = STR_ROAD_SELECT_TYPE_OF_CARGO_FOR;
|
||||
break;
|
||||
|
||||
case VEH_SHIP:
|
||||
this->widget[3].tooltips = STR_983D_SELECT_TYPE_OF_CARGO_FOR;
|
||||
this->widget[6].data = STR_983C_REFIT_SHIP;
|
||||
this->widget[6].tooltips = STR_983E_REFIT_SHIP_TO_CARRY_HIGHLIGHTED;
|
||||
this->widget[2].tooltips = STR_983D_SELECT_TYPE_OF_CARGO_FOR;
|
||||
break;
|
||||
|
||||
case VEH_AIRCRAFT:
|
||||
this->widget[3].tooltips = STR_A03E_SELECT_TYPE_OF_CARGO_FOR;
|
||||
this->widget[6].data = STR_A03D_REFIT_AIRCRAFT;
|
||||
this->widget[6].tooltips = STR_A03F_REFIT_AIRCRAFT_TO_CARRY;
|
||||
this->widget[2].tooltips = STR_A03E_SELECT_TYPE_OF_CARGO_FOR;
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
|
@ -403,7 +407,8 @@ struct RefitWindow : public Window {
|
|||
static const Widget _vehicle_refit_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 239, 14, 27, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, STR_983D_SELECT_TYPE_OF_CARGO_FOR},
|
||||
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 239, 14, 27, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, NULL},
|
||||
|
||||
{ WWT_MATRIX, RESIZE_BOTTOM, COLOUR_GREY, 0, 227, 28, 139, 0x801, STR_EMPTY},
|
||||
{ WWT_SCROLLBAR, RESIZE_BOTTOM, COLOUR_GREY, 228, 239, 28, 139, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WWT_PANEL, RESIZE_TB, COLOUR_GREY, 0, 239, 140, 161, 0x0, STR_NULL},
|
||||
|
|
Loading…
Reference in New Issue