1
0
Fork 0

(svn r15765) [0.7] -Backport from trunk:

- Change: [NewGRF] Expose GRF ID of engines in var action property 0x25 (r15739)
- Fix: Add Engine::GetDisplayDefaultCapacity() and use it everywhere, so CB 36 is also used everywhere (r15763)
- Fix: [Windows] Inlined UTF-8 characters (in the source code) are not handled properly on Eastern versions of Windows so escape them (r15762)
- Fix: [Windows] On some system searching a font using its English name fails. So now we search the font using the localised name and use the English name for the final 'validation' only (r15757)
release/0.7
rubidium 2009-03-18 19:50:34 +00:00
parent 9e592b9986
commit 61e97110c9
14 changed files with 587 additions and 562 deletions

View File

@ -6,9 +6,10 @@
#include "ai_cargo.hpp"
#include "../../company_func.h"
#include "../../strings_func.h"
#include "../../aircraft.h"
#include "../../vehicle_func.h"
#include "../../settings_type.h"
#include "../../rail.h"
#include "../../engine_base.h"
#include "../../articulated_vehicles.h"
#include "table/strings.h"
@ -77,11 +78,8 @@
} break;
case VEH_SHIP:
return e->u.ship.capacity;
break;
case VEH_AIRCRAFT:
return AircraftDefaultCargoCapacity(e->GetDefaultCargoType(), &e->u.air);
return e->GetDisplayDefaultCapacity();
break;
default: NOT_REACHED();

View File

@ -3,9 +3,11 @@
/** @file ai_event_types.cpp Implementation of all EventTypes. */
#include "ai_event_types.hpp"
#include "../../command_type.h"
#include "../../strings_func.h"
#include "../../settings_type.h"
#include "../../aircraft.h"
#include "../../rail.h"
#include "../../engine_base.h"
#include "../../articulated_vehicles.h"
#include "table/strings.h"
@ -41,11 +43,8 @@ int32 AIEventEnginePreview::GetCapacity()
} break;
case VEH_SHIP:
return e->u.ship.capacity;
break;
case VEH_AIRCRAFT:
return AircraftDefaultCargoCapacity(e->GetDefaultCargoType(), &e->u.air);
return e->GetDisplayDefaultCapacity();
break;
default: NOT_REACHED();

View File

@ -5,7 +5,6 @@
#include "stdafx.h"
#include "train.h"
#include "roadveh.h"
#include "aircraft.h"
#include "newgrf_engine.h"
#include "vehicle_func.h"
@ -52,22 +51,7 @@ static inline uint16 GetVehicleDefaultCapacity(EngineID engine, VehicleType type
CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
if (cargo_type != NULL) *cargo_type = cargo;
if (cargo == CT_INVALID) return 0;
switch (type) {
case VEH_TRAIN:
return GetEngineProperty(engine, 0x14, e->u.rail.capacity) + (e->u.rail.railveh_type == RAILVEH_MULTIHEAD ? e->u.rail.capacity : 0);
case VEH_ROAD:
return GetEngineProperty(engine, 0x0F, e->u.road.capacity);
case VEH_SHIP:
return GetEngineProperty(engine, 0x0D, e->u.ship.capacity);
case VEH_AIRCRAFT:
return AircraftDefaultCargoCapacity(cargo, &e->u.air);
default: NOT_REACHED();
}
return e->GetDisplayDefaultCapacity();
}
/**

View File

@ -225,8 +225,11 @@ static int CDECL RoadVehEngineCapacitySorter(const void *a, const void *b)
/* Ship vehicle sorting functions */
static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
{
int va = ShipVehInfo(*(const EngineID*)a)->capacity;
int vb = ShipVehInfo(*(const EngineID*)b)->capacity;
const Engine *e_a = GetEngine(*(const EngineID*)a);
const Engine *e_b = GetEngine(*(const EngineID*)b);
int va = e_a->GetDisplayDefaultCapacity();
int vb = e_b->GetDisplayDefaultCapacity();
int r = va - vb;
/* Use EngineID to sort instead since we want consistent sorting */
@ -240,8 +243,8 @@ static int CDECL AircraftEngineCargoSorter(const void *a, const void *b)
const Engine *e_a = GetEngine(*(const EngineID*)a);
const Engine *e_b = GetEngine(*(const EngineID*)b);
int va = AircraftDefaultCargoCapacity(e_a->GetDefaultCargoType(), &e_a->u.air);
int vb = AircraftDefaultCargoCapacity(e_b->GetDefaultCargoType(), &e_b->u.air);
int va = e_a->GetDisplayDefaultCapacity();
int vb = e_b->GetDisplayDefaultCapacity();
int r = va - vb;
if (r == 0) {
@ -383,7 +386,7 @@ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const
/* Wagon weight - (including cargo) */
uint weight = e->GetDisplayWeight();
SetDParam(0, weight);
uint cargo_weight = (e->CanCarryCargo() ? GetCargo(e->GetDefaultCargoType())->weight * GetEngineProperty(engine_number, 0x14, rvi->capacity) >> 4 : 0);
uint cargo_weight = (e->CanCarryCargo() ? GetCargo(e->GetDefaultCargoType())->weight * e->GetDisplayDefaultCapacity() >> 4 : 0);
SetDParam(1, cargo_weight + weight);
DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, TC_FROMSTRING);
y += 10;
@ -482,7 +485,7 @@ static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const Ship
/* Cargo type + capacity */
SetDParam(0, e->GetDefaultCargoType());
SetDParam(1, GetEngineProperty(engine_number, 0x0D, svi->capacity));
SetDParam(1, e->GetDisplayDefaultCapacity());
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING);
y += 10;
@ -509,14 +512,14 @@ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const
/* Cargo capacity */
if (cargo == CT_INVALID || cargo == CT_PASSENGERS) {
SetDParam(0, avi->passenger_capacity);
SetDParam(0, e->GetDisplayDefaultCapacity());
SetDParam(1, avi->mail_capacity);
DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, TC_FROMSTRING);
} else {
/* Note, if the default capacity is selected by the refit capacity
* callback, then the capacity shown is likely to be incorrect. */
SetDParam(0, cargo);
SetDParam(1, AircraftDefaultCargoCapacity(cargo, avi));
SetDParam(1, e->GetDisplayDefaultCapacity());
SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, TC_FROMSTRING);
}

View File

@ -10,40 +10,40 @@
#include "table/strings.h"
/* exchange rate prefix symbol_pos
* | separator | postfix |
* | | Euro year | | | name
* | | | | | | | */
/* exchange rate prefix symbol_pos
* | separator | postfix |
* | | Euro year | | | name
* | | | | | | | */
static const CurrencySpec origin_currency_specs[NUM_CURRENCY] = {
{ 1, ',', CF_NOEURO, "£", "", 0, STR_CURR_GBP }, ///< british pounds
{ 2, ',', CF_NOEURO, "$", "", 0, STR_CURR_USD }, ///< us dollars
{ 2, ',', CF_ISEURO, "", "", 0, STR_CURR_EUR }, ///< Euro
{ 220, ',', CF_NOEURO, "¥", "", 0, STR_CURR_YEN }, ///< yen
{ 20, ',', 2002, "", " S.", 1, STR_CURR_ATS }, ///< austrian schilling
{ 59, ',', 2002, "BEF ", "", 0, STR_CURR_BEF }, ///< belgian franc
{ 2, ',', CF_NOEURO, "CHF ", "", 0, STR_CURR_CHF }, ///< swiss franc
{ 41, ',', CF_NOEURO, "", "", 1, STR_CURR_CZK }, ///< czech koruna
{ 3, '.', 2002, "DM ", "", 0, STR_CURR_DEM }, ///< deutsche mark
{ 11, '.', CF_NOEURO, "", " kr", 1, STR_CURR_DKK }, ///< danish krone
{ 245, '.', 2002, "Pts ", "", 0, STR_CURR_ESP }, ///< spanish pesetas
{ 9, ',', 2002, "", " mk", 1, STR_CURR_FIM }, ///< finnish markka
{ 10, '.', 2002, "FF ", "", 0, STR_CURR_FRF }, ///< french francs
{ 500, ',', 2002, "", "Dr.", 1, STR_CURR_GRD }, ///< greek drachma
{ 378, ',', CF_NOEURO, "", " Ft", 1, STR_CURR_HUF }, ///< hungarian forint
{ 130, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_ISK }, ///< icelandic krona
{ 2850, ',', 2002, "", " L.", 1, STR_CURR_ITL }, ///< italian lira
{ 3, ',', 2002, "NLG ", "", 0, STR_CURR_NLG }, ///< dutch gulden
{ 12, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_NOK }, ///< norwegian krone
{ 6, ' ', CF_NOEURO, "", " zl", 1, STR_CURR_PLN }, ///< polish zloty
{ 5, '.', CF_NOEURO, "", " Lei", 1, STR_CURR_ROL }, ///< romanian Lei
{ 50, ' ', CF_NOEURO, "", " p", 1, STR_CURR_RUR }, ///< russian rouble
{ 352, '.', 2007, "", " SIT", 1, STR_CURR_SIT }, ///< slovenian tolar
{ 13, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_SEK }, ///< swedish krona
{ 3, '.', CF_NOEURO, "", " TL", 1, STR_CURR_TRY }, ///< turkish lira
{ 52, ',', 2009, "", " Sk", 1, STR_CURR_SKK }, ///< slovak koruna
{ 4, ',', CF_NOEURO, "R$ ", "", 0, STR_CURR_BRL }, ///< brazil real
{ 20, '.', CF_NOEURO, "", " EEK", 1, STR_CURR_EEK }, ///< estonian krooni
{ 1, ' ', CF_NOEURO, "", "", 2, STR_CURR_CUSTOM }, ///< custom currency
{ 1, ',', CF_NOEURO, "\xC2\xA3", "", 0, STR_CURR_GBP }, ///< british pounds
{ 2, ',', CF_NOEURO, "$", "", 0, STR_CURR_USD }, ///< us dollars
{ 2, ',', CF_ISEURO, "\xE2\x82\xAC", "", 0, STR_CURR_EUR }, ///< Euro
{ 220, ',', CF_NOEURO, "\xC2\xA5", "", 0, STR_CURR_YEN }, ///< yen
{ 20, ',', 2002, "", " S.", 1, STR_CURR_ATS }, ///< austrian schilling
{ 59, ',', 2002, "BEF ", "", 0, STR_CURR_BEF }, ///< belgian franc
{ 2, ',', CF_NOEURO, "CHF ", "", 0, STR_CURR_CHF }, ///< swiss franc
{ 41, ',', CF_NOEURO, "", " K\xC4\x8D", 1, STR_CURR_CZK }, ///< czech koruna
{ 3, '.', 2002, "DM ", "", 0, STR_CURR_DEM }, ///< deutsche mark
{ 11, '.', CF_NOEURO, "", " kr", 1, STR_CURR_DKK }, ///< danish krone
{ 245, '.', 2002, "Pts ", "", 0, STR_CURR_ESP }, ///< spanish pesetas
{ 9, ',', 2002, "", " mk", 1, STR_CURR_FIM }, ///< finnish markka
{ 10, '.', 2002, "FF ", "", 0, STR_CURR_FRF }, ///< french francs
{ 500, ',', 2002, "", "Dr.", 1, STR_CURR_GRD }, ///< greek drachma
{ 378, ',', CF_NOEURO, "", " Ft", 1, STR_CURR_HUF }, ///< hungarian forint
{ 130, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_ISK }, ///< icelandic krona
{ 2850, ',', 2002, "", " L.", 1, STR_CURR_ITL }, ///< italian lira
{ 3, ',', 2002, "NLG ", "", 0, STR_CURR_NLG }, ///< dutch gulden
{ 12, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_NOK }, ///< norwegian krone
{ 6, ' ', CF_NOEURO, "", " zl", 1, STR_CURR_PLN }, ///< polish zloty
{ 5, '.', CF_NOEURO, "", " Lei", 1, STR_CURR_ROL }, ///< romanian Lei
{ 50, ' ', CF_NOEURO, "", " p", 1, STR_CURR_RUR }, ///< russian rouble
{ 352, '.', 2007, "", " SIT", 1, STR_CURR_SIT }, ///< slovenian tolar
{ 13, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_SEK }, ///< swedish krona
{ 3, '.', CF_NOEURO, "", " TL", 1, STR_CURR_TRY }, ///< turkish lira
{ 52, ',', 2009, "", " Sk", 1, STR_CURR_SKK }, ///< slovak koruna
{ 4, ',', CF_NOEURO, "R$ ", "", 0, STR_CURR_BRL }, ///< brazil real
{ 20, '.', CF_NOEURO, "", " EEK", 1, STR_CURR_EEK }, ///< estonian krooni
{ 1, ' ', CF_NOEURO, "", "", 2, STR_CURR_CUSTOM }, ///< custom currency
};
/* Array of currencies used by the system */

View File

@ -177,6 +177,36 @@ bool Engine::CanCarryCargo() const
return this->GetDefaultCargoType() != CT_INVALID;
}
/**
* Determines the default cargo capacity of an engine for display purposes.
*
* For planes carrying both passenger and mail this is the passenger capacity.
* For multiheaded engines this is the capacity of both heads.
* For articulated engines use GetCapacityOfArticulatedParts
*
* @return The default capacity
* @see GetDefaultCargoType
*/
uint Engine::GetDisplayDefaultCapacity() const
{
if (!this->CanCarryCargo()) return 0;
switch (type) {
case VEH_TRAIN:
return GetEngineProperty(this->index, 0x14, this->u.rail.capacity) + (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? this->u.rail.capacity : 0);
case VEH_ROAD:
return GetEngineProperty(this->index, 0x0F, this->u.road.capacity);
case VEH_SHIP:
return GetEngineProperty(this->index, 0x0D, this->u.ship.capacity);
case VEH_AIRCRAFT:
return AircraftDefaultCargoCapacity(this->GetDefaultCargoType(), &this->u.air);
default: NOT_REACHED();
}
}
Money Engine::GetRunningCost() const
{
switch (this->type) {

View File

@ -53,6 +53,7 @@ struct Engine : PoolItem<Engine, EngineID, &_Engine_pool> {
CargoID GetDefaultCargoType() const;
bool CanCarryCargo() const;
uint GetDisplayDefaultCapacity() const;
Money GetRunningCost() const;
Money GetCost() const;
uint GetDisplayMaxSpeed() const;

View File

@ -14,7 +14,6 @@
#include "engine_gui.h"
#include "articulated_vehicles.h"
#include "rail.h"
#include "aircraft.h"
#include "table/strings.h"
#include "table/sprites.h"
@ -151,7 +150,7 @@ static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw)
if (cargo == CT_INVALID || cargo == CT_PASSENGERS) {
SetDParam(0, e->GetCost());
SetDParam(1, e->GetDisplayMaxSpeed());
SetDParam(2, e->u.air.passenger_capacity);
SetDParam(2, e->GetDisplayDefaultCapacity());
SetDParam(3, e->u.air.mail_capacity);
SetDParam(4, e->GetRunningCost());
@ -160,7 +159,7 @@ static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw)
SetDParam(0, e->GetCost());
SetDParam(1, e->GetDisplayMaxSpeed());
SetDParam(2, cargo);
SetDParam(3, AircraftDefaultCargoCapacity(cargo, &e->u.air));
SetDParam(3, e->GetDisplayDefaultCapacity());
SetDParam(4, e->GetRunningCost());
DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
@ -187,13 +186,12 @@ static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw)
static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw)
{
const ShipVehicleInfo *svi = ShipVehInfo(engine);
const Engine *e = GetEngine(engine);
SetDParam(0, e->GetCost());
SetDParam(1, e->GetDisplayMaxSpeed());
SetDParam(2, e->GetDefaultCargoType());
SetDParam(3, GetEngineProperty(engine, 0x0D, svi->capacity));
SetDParam(3, e->GetDisplayDefaultCapacity());
SetDParam(4, e->GetRunningCost());
DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
}

View File

@ -172,6 +172,8 @@ static FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
if (err != FT_Err_Ok) break;
if (strncasecmp(font_name, (*face)->family_name, strlen((*face)->family_name)) == 0) break;
/* Try english name if font name failed */
if (strncasecmp(font_name + strlen(font_name) + 1, (*face)->family_name, strlen((*face)->family_name)) == 0) break;
err = FT_Err_Cannot_Open_Resource;
} while ((FT_Long)++index != (*face)->num_faces);
@ -296,12 +298,18 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT
if ((fs.fsCsb[0] & info->locale.lsCsbSupported[0]) == 0 && (fs.fsCsb[1] & info->locale.lsCsbSupported[1]) == 0) return 1;
}
const char *font_name = GetEnglishFontName(logfont);
DEBUG(freetype, 1, "Fallback font: %s", font_name);
const char *english_name = GetEnglishFontName(logfont);
const char *font_name = WIDE_TO_MB((const TCHAR*)logfont->elfFullName);
DEBUG(freetype, 1, "Fallback font: %s (%s)", font_name, english_name);
strecpy(info->settings->small_font, font_name, lastof(info->settings->small_font));
strecpy(info->settings->medium_font, font_name, lastof(info->settings->medium_font));
strecpy(info->settings->large_font, font_name, lastof(info->settings->large_font));
/* Add english name after font name */
strecpy(info->settings->small_font + strlen(info->settings->small_font) + 1, english_name, lastof(info->settings->small_font));
strecpy(info->settings->medium_font + strlen(info->settings->medium_font) + 1, english_name, lastof(info->settings->medium_font));
strecpy(info->settings->large_font + strlen(info->settings->large_font) + 1, english_name, lastof(info->settings->large_font));
return 0; // stop enumerating
}

View File

@ -315,7 +315,7 @@ struct AboutWindow : public Window {
" Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework",
" Victor Fischer (Celestar) - Programming everywhere you need him to",
" Christoph Elsenhans (frosch) - General coding",
" Loïc Guilloux (glx) - Windows Expert",
" Lo\xC3\xAF""c Guilloux (glx) - Windows Expert",
" Michael Lutz (michi_cc) - Path based signals",
" Owen Rudge (orudge) - Forum host, OS/2 port",
" Peter Nelson (peter1138) - Spiritual descendant from newGRF gods",
@ -324,10 +324,10 @@ struct AboutWindow : public Window {
" Thijs Marinussen (Yexo) - AI Framework",
"",
"Inactive Developers:",
" Tamás Faragó (Darkvater) - Ex-Lead coder",
" Tam\xC3\xA1s Farag\xC3\xB3 (Darkvater) - Ex-Lead coder",
" Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)",
" Jonathan Coome (Maedhros) - High priest of the NewGRF Temple",
" Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
" Attila B\xC3\xA1n (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host",
" Christoph Mallon (Tron) - Programmer, code correctness police",
"",
"Retired Developers:",

View File

@ -295,7 +295,7 @@ static byte MakeFinnishTownName(char *buf, uint32 seed, const char *last)
{
strecat(buf, "la", last);
} else {
strecat(buf, "lä", last);
strecat(buf, "l\xC3\xA4", last);
}
} else {
/* A two-part name by combining one of _name_finnish_{1,2} + _name_finnish_3.

View File

@ -122,7 +122,8 @@ const GRFFile *GetEngineGRF(EngineID engine)
*/
uint32 GetEngineGRFID(EngineID engine)
{
return GetEngineGRF(engine)->grfid;
const GRFFile *file = GetEngineGRF(engine);
return file == NULL ? 0 : file->grfid;
}
@ -500,6 +501,9 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
/* Calculated vehicle parameters */
switch (variable) {
case 0x25: // Get engine GRF ID
return GetEngineGRFID(v->engine_type);
case 0x40: // Get length of consist
if (!HasBit(v->cache_valid, 0)) {
v->cached_var40 = PositionHelper(v, false);

View File

@ -85,7 +85,7 @@ BEGIN
VALUE "FileDescription", "OpenTTD\0"
VALUE "FileVersion", "Development @@VERSION@@\0"
VALUE "InternalName", "openttd\0"
VALUE "LegalCopyright", "Copyright © OpenTTD Developers 2002-2009. All Rights Reserved.\0"
VALUE "LegalCopyright", "Copyright \xA9 OpenTTD Developers 2002-2009. All Rights Reserved.\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "openttd.exe\0"
VALUE "PrivateBuild", "\0"

File diff suppressed because it is too large Load Diff