Merge branch 'master' into jgrpp

# Conflicts:
#	src/core/strong_typedef_type.hpp
#	src/gfx.cpp
#	src/group_cmd.cpp
#	src/industry_cmd.cpp
#	src/map_func.h
#	src/newgrf_debug_gui.cpp
#	src/order_cmd.cpp
#	src/pathfinder/follow_track.hpp
#	src/rail_cmd.cpp
#	src/road_cmd.cpp
#	src/road_gui.cpp
#	src/saveload/saveload.cpp
#	src/screenshot.cpp
#	src/smallmap_gui.cpp
#	src/station_cmd.cpp
#	src/strings.cpp
#	src/tile_type.h
#	src/timetable_gui.cpp
#	src/town_cmd.cpp
#	src/train_cmd.cpp
#	src/viewport.cpp
pull/484/head
Jonathan G Rennison 1 year ago
commit 483e3172af

@ -446,11 +446,11 @@ bool SQFunctionProto::Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr
for(i = 0; i < noutervalues; i++){
SQUnsignedInteger type;
SQObjectPtr name;
SQObjectPtr value_name;
_CHECK_IO(SafeRead(v,read,up, &type, sizeof(SQUnsignedInteger)));
_CHECK_IO(ReadObject(v, up, read, o));
_CHECK_IO(ReadObject(v, up, read, name));
f->_outervalues[i] = SQOuterVar(name,o, (SQOuterType)type);
_CHECK_IO(ReadObject(v, up, read, value_name));
f->_outervalues[i] = SQOuterVar(value_name,o, (SQOuterType)type);
}
_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));

@ -246,9 +246,9 @@ void SQSharedState::DelayFinalFree(SQCollectable *collectable)
if (!this->_collectable_free_processing) {
this->_collectable_free_processing = true;
while (!this->_collectable_free_queue.empty()) {
SQCollectable *collectable = this->_collectable_free_queue.back();
SQCollectable *collectable_to_free = this->_collectable_free_queue.back();
this->_collectable_free_queue.pop_back();
collectable->FinalFree();
collectable_to_free->FinalFree();
}
this->_collectable_free_processing = false;
}

@ -1064,11 +1064,11 @@ exception_trap:
if(traps) {
do {
if(ci->_etraps > 0) {
SQExceptionTrap &et = _etraps.top();
ci->_ip = et._ip;
_top = et._stacksize;
_stackbase = et._stackbase;
_stack._vals[_stackbase+et._extarget] = currerror;
SQExceptionTrap &trap = _etraps.top();
ci->_ip = trap._ip;
_top = trap._stacksize;
_stackbase = trap._stackbase;
_stack._vals[_stackbase+trap._extarget] = currerror;
_etraps.pop_back(); traps--; ci->_etraps--;
CLEARSTACK(last_top);
goto exception_restore;

@ -48,7 +48,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
this->description[std::string{}] = *item->value;
/* Add the translations of the descriptions too. */
for (const IniItem *item = metadata->item; item != nullptr; item = item->next) {
for (item = metadata->item; item != nullptr; item = item->next) {
if (item->name.compare(0, 12, "description.") != 0) continue;
this->description[item->name.substr(12)] = item->value.value_or("");

@ -685,7 +685,6 @@ private:
void ShowColourDropDownMenu(uint32 widget)
{
uint32 used_colours = 0;
const Company *c;
const Livery *livery, *default_livery = nullptr;
bool primary = widget == WID_SCL_PRI_COL_DROPDOWN;
byte default_col = 0;
@ -697,7 +696,7 @@ private:
}
}
c = Company::Get((CompanyID)this->window_number);
const Company *c = Company::Get((CompanyID)this->window_number);
if (this->livery_class < LC_GROUP_RAIL) {
/* Get the first selected livery to use as the default dropdown item */

@ -144,4 +144,46 @@ private:
const int line;
};
/**
* Class to backup a specific variable and restore it upon destruction of this object to prevent
* stack values going out of scope before resetting the global to its original value. Contrary to
* #Backup this restores the variable automatically and there is no manual option to restore.
*/
template <typename T>
struct AutoRestoreBackup {
/*
* There is explicitly no only original constructor version, as that would make it possible
* for the new value to go out of scope before this object goes out of scope, thus defeating
* the whole goal and reason for existing of this object.
*/
/**
* Backup variable and switch to new value.
* @param original Variable to backup.
* @param new_value New value for variable.
*/
AutoRestoreBackup(T &original, T new_value) : original(original), original_value(original)
{
original = new_value;
}
/**
* Restore the variable upon object destruction.
*/
~AutoRestoreBackup()
{
this->original = this->original_value;
}
private:
T &original;
T original_value;
/* Prevent copy, assignment and allocation on stack. */
AutoRestoreBackup(const AutoRestoreBackup&) = delete;
AutoRestoreBackup& operator=(AutoRestoreBackup&) = delete;
static void *operator new(std::size_t) = delete;
static void *operator new[](std::size_t) = delete;
};
#endif /* BACKUP_TYPE_HPP */

@ -31,7 +31,7 @@
* @return The selected bits, aligned to a LSB.
*/
template <typename T>
static inline uint GB(const T x, const uint8 s, const uint8 n)
debug_inline static uint GB(const T x, const uint8 s, const uint8 n)
{
return (x >> s) & (((T)1U << n) - 1);
}
@ -103,7 +103,7 @@ static inline T AB(T &x, const uint8 s, const uint8 n, const U i)
* @return True if the bit is set, false else.
*/
template <typename T>
static inline bool HasBit(const T x, const uint8 y)
debug_inline static bool HasBit(const T x, const uint8 y)
{
return (x & ((T)1U << y)) != 0;
}

@ -25,6 +25,7 @@
#include "hotkeys.h"
#include "gui.h"
#include "zoom_func.h"
#include "core/backup_type.hpp"
#include "widgets/dock_widget.h"
@ -544,15 +545,13 @@ public:
Axis axis = widget == WID_BDD_X ? AXIS_X : AXIS_Y;
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(96)) / 2;
int y = (r.Height() - ScaleSpriteTrad(64)) / 2;
int x1 = ScaleSpriteTrad(63);
int x2 = ScaleSpriteTrad(31);
DrawShipDepotSprite(x + (axis == AXIS_X ? x1 : x2), y + ScaleSpriteTrad(17), axis, DEPOT_PART_NORTH);
DrawShipDepotSprite(x + (axis == AXIS_X ? x2 : x1), y + ScaleSpriteTrad(33), axis, DEPOT_PART_SOUTH);
_cur_dpi = old_dpi;
}
break;
}

@ -1367,7 +1367,6 @@ void DoPaletteAnimations()
const ExtraPaletteValues *ev = &_extra_palette_values;
Colour old_val[PALETTE_ANIM_SIZE];
const uint old_tc = palette_animation_counter;
uint i;
uint j;
if (blitter != nullptr && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) {
@ -1382,7 +1381,7 @@ void DoPaletteAnimations()
/* Fizzy Drink bubbles animation */
s = ev->fizzy_drink;
j = EXTR2(512, EPV_CYCLES_FIZZY_DRINK);
for (i = 0; i != EPV_CYCLES_FIZZY_DRINK; i++) {
for (uint i = 0; i != EPV_CYCLES_FIZZY_DRINK; i++) {
*palette_pos++ = s[j];
j++;
if (j == EPV_CYCLES_FIZZY_DRINK) j = 0;
@ -1391,7 +1390,7 @@ void DoPaletteAnimations()
/* Oil refinery fire animation */
s = ev->oil_refinery;
j = EXTR2(512, EPV_CYCLES_OIL_REFINERY);
for (i = 0; i != EPV_CYCLES_OIL_REFINERY; i++) {
for (uint i = 0; i != EPV_CYCLES_OIL_REFINERY; i++) {
*palette_pos++ = s[j];
j++;
if (j == EPV_CYCLES_OIL_REFINERY) j = 0;
@ -1431,7 +1430,7 @@ void DoPaletteAnimations()
/* Handle lighthouse and stadium animation */
s = ev->lighthouse;
j = EXTR(256, EPV_CYCLES_LIGHTHOUSE);
for (i = 0; i != EPV_CYCLES_LIGHTHOUSE; i++) {
for (uint i = 0; i != EPV_CYCLES_LIGHTHOUSE; i++) {
*palette_pos++ = s[j];
j++;
if (j == EPV_CYCLES_LIGHTHOUSE) j = 0;
@ -1440,7 +1439,7 @@ void DoPaletteAnimations()
/* Dark blue water */
s = (_settings_game.game_creation.landscape == LT_TOYLAND) ? ev->dark_water_toyland : ev->dark_water;
j = EXTR(320, EPV_CYCLES_DARK_WATER);
for (i = 0; i != EPV_CYCLES_DARK_WATER; i++) {
for (uint i = 0; i != EPV_CYCLES_DARK_WATER; i++) {
*palette_pos++ = s[j];
j++;
if (j == EPV_CYCLES_DARK_WATER) j = 0;
@ -1449,7 +1448,7 @@ void DoPaletteAnimations()
/* Glittery water */
s = (_settings_game.game_creation.landscape == LT_TOYLAND) ? ev->glitter_water_toyland : ev->glitter_water;
j = EXTR(128, EPV_CYCLES_GLITTER_WATER);
for (i = 0; i != EPV_CYCLES_GLITTER_WATER / 3; i++) {
for (uint i = 0; i != EPV_CYCLES_GLITTER_WATER / 3; i++) {
*palette_pos++ = s[j];
j += 3;
if (j >= EPV_CYCLES_GLITTER_WATER) j -= EPV_CYCLES_GLITTER_WATER;

@ -664,10 +664,8 @@ void AnimateTile_Industry(TileIndex tile)
case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6:
case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8:
if ((_scaled_tick_counter & 3) == 0) {
IndustryGfx gfx = GetIndustryGfx(tile);
gfx = (gfx < 155) ? gfx + 1 : 148;
SetIndustryGfx(tile, gfx);
IndustryGfx new_gfx = (gfx < 155) ? gfx + 1 : 148;
SetIndustryGfx(tile, new_gfx);
MarkTileDirtyByTile(tile, VMDF_NOT_MAP_MODE);
}
break;
@ -677,8 +675,6 @@ void AnimateTile_Industry(TileIndex tile)
case GFX_OILWELL_ANIMATED_3:
if ((_scaled_tick_counter & 7) == 0) {
bool b = Chance16(1, 7);
IndustryGfx gfx = GetIndustryGfx(tile);
byte m = GetAnimationFrame(tile) + 1;
if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) {
SetIndustryGfx(tile, GFX_OILWELL_NOT_ANIMATED);

@ -2790,12 +2790,12 @@ struct IndustryCargoesWindow : public Window {
_displayed_industries_out.set(displayed_it);
this->fields.clear();
CargoesRow &row = this->fields.emplace_back();
row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
row.columns[1].MakeEmpty(CFT_SMALL_EMPTY);
row.columns[2].MakeEmpty(CFT_SMALL_EMPTY);
row.columns[3].MakeEmpty(CFT_SMALL_EMPTY);
row.columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
CargoesRow &first_row = this->fields.emplace_back();
first_row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
first_row.columns[1].MakeEmpty(CFT_SMALL_EMPTY);
first_row.columns[2].MakeEmpty(CFT_SMALL_EMPTY);
first_row.columns[3].MakeEmpty(CFT_SMALL_EMPTY);
first_row.columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
const IndustrySpec *central_sp = GetIndustrySpec(displayed_it);
bool houses_supply = HousesCanSupply(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo));
@ -2871,12 +2871,12 @@ struct IndustryCargoesWindow : public Window {
_displayed_industries_out.reset();
this->fields.clear();
CargoesRow &row = this->fields.emplace_back();
row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
row.columns[1].MakeEmpty(CFT_SMALL_EMPTY);
row.columns[2].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
row.columns[3].MakeEmpty(CFT_SMALL_EMPTY);
row.columns[4].MakeEmpty(CFT_SMALL_EMPTY);
CargoesRow &first_row = this->fields.emplace_back();
first_row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
first_row.columns[1].MakeEmpty(CFT_SMALL_EMPTY);
first_row.columns[2].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
first_row.columns[3].MakeEmpty(CFT_SMALL_EMPTY);
first_row.columns[4].MakeEmpty(CFT_SMALL_EMPTY);
bool houses_supply = HousesCanSupply(&cid, 1);
bool houses_accept = HousesCanAccept(&cid, 1);
@ -2956,10 +2956,9 @@ struct IndustryCargoesWindow : public Window {
if (widget != WID_IC_PANEL) return;
Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
DrawPixelInfo tmp_dpi, *old_dpi;
DrawPixelInfo tmp_dpi;
if (!FillDrawPixelInfo(&tmp_dpi, ir.left, ir.top, ir.Width(), ir.Height())) return;
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int left_pos = ir.left;
if (this->ind_cargo >= NUM_INDUSTRYTYPES) left_pos += (CargoesField::industry_width + CargoesField::cargo_field_width) / 2;
@ -2988,8 +2987,6 @@ struct IndustryCargoesWindow : public Window {
vpos += row_height;
if (vpos >= height) break;
}
_cur_dpi = old_dpi;
}
/**

@ -2713,6 +2713,10 @@ STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP :{BLACK}Augmenta
STR_SELECT_RAIL_BRIDGE_CAPTION :{WHITE}Selecciona Pont de Tren
STR_SELECT_ROAD_BRIDGE_CAPTION :{WHITE}Selecciona Pont de Carretera
STR_SELECT_BRIDGE_SELECTION_TOOLTIP :{BLACK}Selecció de pont - clica sobre el pont triat per construir-lo
STR_SELECT_BRIDGE_INFO_NAME :{GOLD}{STRING}
STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED :{GOLD}{STRING},{} {VELOCITY}
STR_SELECT_BRIDGE_INFO_NAME_COST :{GOLD}{0:STRING},{} {WHITE}{2:CURRENCY_LONG}
STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED_COST :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY_LONG}
STR_BRIDGE_NAME_SUSPENSION_STEEL :Pont penjant d'acer
STR_BRIDGE_NAME_GIRDER_STEEL :Pont biga d'acer
STR_BRIDGE_NAME_CANTILEVER_STEEL :Pont en mènsula d'acer

@ -971,6 +971,7 @@ STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS :כל 12 חוד
STR_GAME_OPTIONS_LANGUAGE :{BLACK}שפה
STR_GAME_OPTIONS_LANGUAGE_TOOLTIP :{BLACK}בחר את שפת הממשק
STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE :{STRING} ({NUM}% הסתיים)
STR_GAME_OPTIONS_FULLSCREEN :{BLACK}מסך מלא
STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP :{BLACK}סמן תיבה זו כדי לשחק OpenTTD על כל המסך
@ -1712,6 +1713,7 @@ STR_CONFIG_SETTING_COLOURED_NEWS_YEAR :{STRING} :הצ
STR_CONFIG_SETTING_COLOURED_NEWS_YEAR_HELPTEXT :השנה בה הודעות העיתונות מודפסות בצבע. לפני שנה זו הן מודפסות בשחור-לבן.
STR_CONFIG_SETTING_STARTING_YEAR :{STRING} :שנת התחלה
STR_CONFIG_SETTING_ENDING_YEAR :ניקוד סוף שנה: {STRING}
###setting-zero-is-special
STR_CONFIG_SETTING_ENDING_YEAR_ZERO :לעולם לא
@ -1722,6 +1724,7 @@ STR_CONFIG_SETTING_ECONOMY_TYPE_ORIGINAL :מקורי
STR_CONFIG_SETTING_ALLOW_SHARES :אפשר קניית מניות מחברות אחרות: {STRING}
STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT :כאשר מאופשר, מתיר קנייה ומכירה של מניות של חברות. מניות יהיו זמינות רק עבור חברות המגיעות לגיל מסוים
STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES :גיל מינימלי לחברה לסחור במניותיה: {STRING}
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE :אחוז הרווח מקטע נסיעה לתשלום במערכות הזנה: {STRING}
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE_HELPTEXT :אחוז הרווח הניתן לקטעי ביניים במערכות הזנה, דבר הנותן שליטה מוגברת על ההכנסות
@ -1774,6 +1777,7 @@ STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT :לינארי
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :מיקום עצים במהלך המשחק: {STRING}
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :שלוט בהופעה אקראית של עצים במהלך המשחק. זה עלול להשפיע על תעשיות המסתמכות על צמיחת עצים, לדוגמא מנסרות
###length 4
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_SPREAD_ALL :גדל ומתפשט בכל מקום
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NO_GROWTH_NO_SPREAD :אל תגדל, אל תתפשט {RED}(שובר מנסרות)
STR_CONFIG_SETTING_TOOLBAR_POS :{STRING} :מיקום הסרגל העיקרי
@ -2154,6 +2158,7 @@ STR_NETWORK_SERVER_LIST_GAMESCRIPT :{SILVER}סקר
STR_NETWORK_SERVER_LIST_PASSWORD :{SILVER}מוגן בסיסמה!
STR_NETWORK_SERVER_LIST_SERVER_OFFLINE :{SILVER}שרת מנותק
STR_NETWORK_SERVER_LIST_SERVER_FULL :{SILVER}שרת מלא
STR_NETWORK_SERVER_LIST_SERVER_TOO_OLD :{SILVER}השרת ישן מדי
STR_NETWORK_SERVER_LIST_VERSION_MISMATCH :{SILVER}גרסה לא תואמת
STR_NETWORK_SERVER_LIST_GRF_MISMATCH :{SILVER}אי התאמת קבצים גרפיים
@ -4336,6 +4341,7 @@ STR_AI_LIST_CANCEL :{BLACK}בטל
STR_AI_LIST_CANCEL_TOOLTIP :{BLACK}אל תשנה את התסריט
STR_SCREENSHOT_CAPTION :{WHITE}צלם מסך
STR_SCREENSHOT_SCREENSHOT :תמונת מסך רגילה
STR_SCREENSHOT_DEFAULTZOOM_SCREENSHOT :{BLACK}זום ברירת מחדל לצילום מסך
STR_SCREENSHOT_WORLD_SCREENSHOT :{BLACK}צילום מסך של כל המפה

@ -1937,13 +1937,13 @@ STR_CONFIG_SETTING_LINKGRAPH_TIME :Dağıtım graf
STR_CONFIG_SETTING_LINKGRAPH_TIME_HELPTEXT :Bağlantı grafiğini oluşturan parçaların her tekrar hesaplaması için kullanılan zaman. Tekrar hesaplama başlatıldığında bu kadar gün sürecek bir işlem başlatılmış olur. Buraya daha kısa süreler girdikçe işlemin bitmesi gerekirken bitmemiş olma ihtimali artar. Ardından oyun ("lag") olana dek durur. Daha uzun süreler girdiğinizde güzergahlar değiştikçe dağıtımın güncellenmesi daha uzun sürer.
STR_CONFIG_SETTING_DISTRIBUTION_PAX :Yolcular için dağıtım kipi: {STRING}
STR_CONFIG_SETTING_DISTRIBUTION_PAX_HELPTEXT :"simetrik" seçildiğinde A durağından B durağına taşınan ile B'den A'ya taşınan yolcu miktarı kabaca eşit olur. "asimetrik" seçildiğinde iki yönde de rastgele miktarda yolcu gönderilebilir. "el ile" seçildiğinde yolcular için otomatik dağıtım yapılmaz.
STR_CONFIG_SETTING_DISTRIBUTION_PAX_HELPTEXT :"Simetrik" seçildiğinde A durağından B durağına taşınan ile B'den A'ya taşınan yolcu miktarı kabaca eşit olur. "Asimetrik" seçildiğinde iki yönde de rastgele miktarda yolcu gönderilebilir. "el ile" seçildiğinde yolcular için otomatik dağıtım yapılmaz.
STR_CONFIG_SETTING_DISTRIBUTION_MAIL :Posta için dağıtım kipi: {STRING}
STR_CONFIG_SETTING_DISTRIBUTION_MAIL_HELPTEXT :"simetrik" seçildiğinde A durağından B durağına gönderilen ile B'den A'ya gönderilen posta miktarı kabaca eşit olur. "asimetrik" seçildiğinde iki yönde de rastgele miktarda posta gönderilebilir. "el ile" seçildiğinde posta için otomatik dağıtım yapılmaz.
STR_CONFIG_SETTING_DISTRIBUTION_MAIL_HELPTEXT :"Simetrik" seçildiğinde A durağından B durağına gönderilen ile B'den A'ya gönderilen posta miktarı kabaca eşit olur. "Asimetrik" seçildiğinde iki yönde de rastgele miktarda posta gönderilebilir. "El ile" seçildiğinde posta için otomatik dağıtım yapılmaz.
STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED :ZIRHLI kargo sınıfı için dağıtım kipi: {STRING}
STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED_HELPTEXT :ZIRHLI kargo sınıfı ılıman iklimde değerli mallar, yarı-tropik iklimde elmaslar, veya yarı-soğuk iklimde altın içerir. NewGRF dosyaları bunu değiştirebilir. "Simetrik" olarak ayarlandığında A durağından B durağına gönderilen kargo miktarı, B'den A'ya gönderilene kabaca eşit olur. "Asimetrik" ise herhangi bir yönde rastgele miktarda kargo gönderilebileceğini gösterir. "El ile" seçildiğinde o kargo için otomatik dağıtım yapılmaz. Yarı-soğuk iklimde oynarken bu değeri "asimetrik" veya "el ile" olarak ayarlamanız tavsiye edilir, çünkü bankalar altınları altın madenine geri göndermez. Ilıman ve yarı-tropik iklim için aynı zamanda "simetrik" seçebilirsiniz, zira bankalar değerli malların bir kısmını malların geldiği kaynak bankaya geri gönderir.
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT :Diğer kargo sınıfları için dağılım kipi: {STRING}
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT_HELPTEXT :"asimetrik", kargonun iki yönde de rastgele miktarda gönderileceğini gösterir. "el ile" seçildiği takdirde o kargolar için otomatik dağılım yapılmaz.
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT_HELPTEXT :"Asimetrik", kargonun iki yönde de rastgele miktarda gönderileceğini gösterir. "El ile" seçildiği takdirde o kargolar için otomatik dağılım yapılmaz.
###length 3
STR_CONFIG_SETTING_DISTRIBUTION_MANUAL :el ile (manual)
STR_CONFIG_SETTING_DISTRIBUTION_ASYMMETRIC :asimetrik
@ -2712,6 +2712,10 @@ STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP :{BLACK}Sinyal s
STR_SELECT_RAIL_BRIDGE_CAPTION :{WHITE}Tren Köprüsü Seç
STR_SELECT_ROAD_BRIDGE_CAPTION :{WHITE}Köprü Seç
STR_SELECT_BRIDGE_SELECTION_TOOLTIP :{BLACK}Köprü seçimi - tercih ettiğiniz köprüyü yapmak için tıklayın
STR_SELECT_BRIDGE_INFO_NAME :{GOLD}{STRING}
STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED :{GOLD}{STRING},{} {VELOCITY}
STR_SELECT_BRIDGE_INFO_NAME_COST :{GOLD}{0:STRING},{} {WHITE}{2:CURRENCY_LONG}
STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED_COST :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY_LONG}
STR_BRIDGE_NAME_SUSPENSION_STEEL :Çelik, Asma
STR_BRIDGE_NAME_GIRDER_STEEL :Çelik, Kirişli
STR_BRIDGE_NAME_CANTILEVER_STEEL :Çelik, Ağ

@ -161,7 +161,7 @@ typedef int32 TileIndexDiff;
* @param y The y coordinate of the tile
* @return The TileIndex calculated by the coordinate
*/
static inline TileIndex TileXY(uint x, uint y)
debug_inline static TileIndex TileXY(uint x, uint y)
{
return (y << MapLogX()) + x;
}
@ -192,7 +192,7 @@ static inline TileIndexDiff TileDiffXY(int x, int y)
* @param y The virtual y coordinate of the tile.
* @return The TileIndex calculated by the coordinate.
*/
static inline TileIndex TileVirtXY(uint x, uint y)
debug_inline static TileIndex TileVirtXY(uint x, uint y)
{
return (y >> 4 << MapLogX()) + (x >> 4);
}
@ -216,7 +216,7 @@ static inline TileIndex TileVirtXYClampedToMap(int x, int y)
* @param tile the tile to get the X component of
* @return the X component
*/
static inline uint TileX(TileIndex tile)
debug_inline static uint TileX(TileIndex tile)
{
return tile & MapMaxX();
}
@ -226,7 +226,7 @@ static inline uint TileX(TileIndex tile)
* @param tile the tile to get the Y component of
* @return the Y component
*/
static inline uint TileY(TileIndex tile)
debug_inline static uint TileY(TileIndex tile)
{
return tile >> MapLogX();
}

@ -29,6 +29,7 @@
#include "guitimer_func.h"
#include "viewport_func.h"
#include "rev.h"
#include "core/backup_type.hpp"
#include "widgets/misc_widget.h"
@ -893,8 +894,7 @@ void QueryString::DrawEditBox(const Window *w, int wid) const
DrawPixelInfo dpi;
if (!FillDrawPixelInfo(&dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &dpi);
/* We will take the current widget length as maximum width, with a small
* space reserved at the end for the caret to show */
@ -912,8 +912,6 @@ void QueryString::DrawEditBox(const Window *w, int wid) const
int caret_width = GetStringBoundingBox("_").width;
DrawString(tb->caretxoffs + delta, tb->caretxoffs + delta + caret_width, 0, "_", TC_WHITE);
}
_cur_dpi = old_dpi;
}
/**

@ -1060,11 +1060,11 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
* After that's done run over them once again to test their children
* to unselect. Don't do it immediately because it'll do exactly what
* we're doing now. */
for (const ContentInfo *c : parents) {
if (c->state == ContentInfo::AUTOSELECTED) this->Unselect(c->id);
for (const ContentInfo *parent : parents) {
if (parent->state == ContentInfo::AUTOSELECTED) this->Unselect(parent->id);
}
for (const ContentInfo *c : parents) {
this->CheckDependencyState(this->GetContent(c->id));
for (const ContentInfo *parent : parents) {
this->CheckDependencyState(this->GetContent(parent->id));
}
}
}

@ -4510,13 +4510,13 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, const
int n = buf->ReadByte();
for (int j = 0; j != n; j++) {
RailTypeLabel label = buf->ReadDWord();
RailType rt = GetRailTypeByLabel(BSWAP32(label), false);
if (rt != INVALID_RAILTYPE) {
RailType resolved_rt = GetRailTypeByLabel(BSWAP32(label), false);
if (resolved_rt != INVALID_RAILTYPE) {
switch (prop) {
case 0x0F: SetBit(rti->powered_railtypes, rt); FALLTHROUGH; // Powered implies compatible.
case 0x0E: SetBit(rti->compatible_railtypes, rt); break;
case 0x18: SetBit(rti->introduction_required_railtypes, rt); break;
case 0x19: SetBit(rti->introduces_railtypes, rt); break;
case 0x0F: SetBit(rti->powered_railtypes, resolved_rt); FALLTHROUGH; // Powered implies compatible.
case 0x0E: SetBit(rti->compatible_railtypes, resolved_rt); break;
case 0x18: SetBit(rti->introduction_required_railtypes, resolved_rt); break;
case 0x19: SetBit(rti->introduces_railtypes, resolved_rt); break;
}
}
}
@ -4763,12 +4763,12 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, const
int n = buf->ReadByte();
for (int j = 0; j != n; j++) {
RoadTypeLabel label = buf->ReadDWord();
RoadType rt = GetRoadTypeByLabel(BSWAP32(label), false);
if (rt != INVALID_ROADTYPE) {
RoadType resolved_rt = GetRoadTypeByLabel(BSWAP32(label), false);
if (resolved_rt != INVALID_ROADTYPE) {
switch (prop) {
case 0x0F: SetBit(rti->powered_roadtypes, rt); break;
case 0x18: SetBit(rti->introduction_required_roadtypes, rt); break;
case 0x19: SetBit(rti->introduces_roadtypes, rt); break;
case 0x0F: SetBit(rti->powered_roadtypes, resolved_rt); break;
case 0x18: SetBit(rti->introduction_required_roadtypes, resolved_rt); break;
case 0x19: SetBit(rti->introduces_roadtypes, resolved_rt); break;
}
}
}

@ -10,6 +10,7 @@
#include "stdafx.h"
#include <stdarg.h>
#include <functional>
#include "core/backup_type.hpp"
#include "window_gui.h"
#include "window_func.h"
#include "random_access_file_type.h"
@ -1324,17 +1325,13 @@ struct SpriteAlignerWindow : Window {
DrawPixelInfo new_dpi;
if (!FillDrawPixelInfo(&new_dpi, ir.left, ir.top, ir.Width(), ir.Height())) break;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &new_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &new_dpi);
DrawSprite(this->current_sprite, PAL_NONE, x, y, nullptr, ZOOM_LVL_GUI);
if (this->crosshair) {
GfxDrawLine(x, 0, x, ir.Height() - 1, PC_WHITE, 1, 1);
GfxDrawLine(0, y, ir.Width() - 1, y, PC_WHITE, 1, 1);
}
_cur_dpi = old_dpi;
break;
}

@ -1289,16 +1289,16 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
WIDGET_LIST_END
);
const GRFConfig *c = (this->avail_sel == nullptr) ? this->active_sel : this->avail_sel;
const GRFConfig *selected_config = (this->avail_sel == nullptr) ? this->active_sel : this->avail_sel;
for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, c == nullptr || c->GetTextfile(tft) == nullptr);
this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, selected_config == nullptr || selected_config->GetTextfile(tft) == nullptr);
}
this->SetWidgetDisabledState(WID_NS_OPEN_URL, c == nullptr || StrEmpty(c->GetURL()));
this->SetWidgetDisabledState(WID_NS_OPEN_URL, selected_config == nullptr || StrEmpty(selected_config->GetURL()));
this->SetWidgetDisabledState(WID_NS_SET_PARAMETERS, !this->show_params || this->active_sel == nullptr || this->active_sel->num_valid_params == 0);
this->SetWidgetDisabledState(WID_NS_VIEW_PARAMETERS, !this->show_params || this->active_sel == nullptr || this->active_sel->num_valid_params == 0);
this->SetWidgetDisabledState(WID_NS_TOGGLE_PALETTE, disable_all ||
(!(_settings_client.gui.newgrf_developer_tools || _settings_client.gui.scenario_developer) && ((c->palette & GRFP_GRF_MASK) != GRFP_GRF_UNSET)));
(!(_settings_client.gui.newgrf_developer_tools || _settings_client.gui.scenario_developer) && ((selected_config->palette & GRFP_GRF_MASK) != GRFP_GRF_UNSET)));
if (!disable_all) {
/* All widgets are now enabled, so disable widgets we can't use */

@ -24,6 +24,7 @@
#include "window_gui.h"
#include "window_func.h"
#include "zoom_func.h"
#include "core/backup_type.hpp"
#include "widgets/object_widget.h"
@ -360,8 +361,7 @@ public:
DrawPixelInfo tmp_dpi;
/* Set up a clipping area for the preview. */
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
if (spec->grf_prop.grffile == nullptr) {
extern const DrawTileSprites _objects[];
const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
@ -369,7 +369,6 @@ public:
} else {
DrawNewObjectTileInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, GB(widget, 16, 16));
}
_cur_dpi = old_dpi;
}
break;
}
@ -387,8 +386,7 @@ public:
DrawPixelInfo tmp_dpi;
/* Set up a clipping area for the preview. */
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
if (spec->grf_prop.grffile == nullptr) {
extern const DrawTileSprites _objects[];
const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
@ -397,7 +395,6 @@ public:
DrawNewObjectTileInGUI(r.Width() / 2 - 1, r.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec,
std::min<int>(_selected_object_view, spec->views - 1));
}
_cur_dpi = old_dpi;
}
break;
}

@ -1980,7 +1980,7 @@ void StateGameLoop()
#ifndef DEBUG_DUMP_COMMANDS
{
PerformanceMeasurer framerate(PFE_ALLSCRIPTS);
PerformanceMeasurer script_framerate(PFE_ALLSCRIPTS);
AI::GameLoop();
Game::GameLoop();
}

@ -2402,7 +2402,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
/* Sanity checks */
if (src == nullptr || !src->IsPrimaryVehicle() || dst->type != src->type || dst == src) return CMD_ERROR;
CommandCost ret = CheckOwnership(src->owner);
ret = CheckOwnership(src->owner);
if (ret.Failed()) return ret;
/* Trucks can't share orders with busses (and visa versa) */
@ -2495,7 +2495,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
/* Sanity checks */
if (src == nullptr || !src->IsPrimaryVehicle() || dst->type != src->type || dst == src) return CMD_ERROR;
CommandCost ret = CheckOwnership(src->owner);
ret = CheckOwnership(src->owner);
if (ret.Failed()) return ret;
/* Trucks can't copy all the orders from busses (and visa versa),
@ -2754,7 +2754,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool
for (Vehicle *v : Vehicle::Iterate()) {
Order *order = &v->current_order;
if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) && !hangar ? OT_GOTO_STATION : order->GetType()) == type &&
(!hangar || v->type == VEH_AIRCRAFT) && v->current_order.GetDestination() == destination) {
(!hangar || v->type == VEH_AIRCRAFT) && order->GetDestination() == destination) {
order->MakeDummy();
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
}

@ -87,11 +87,11 @@ struct CFollowTrackT
m_railtypes = railtype_override;
}
inline static TransportType TT() { return Ttr_type_; }
inline static bool IsWaterTT() { return TT() == TRANSPORT_WATER; }
inline static bool IsRailTT() { return TT() == TRANSPORT_RAIL; }
debug_inline static TransportType TT() { return Ttr_type_; }
debug_inline static bool IsWaterTT() { return TT() == TRANSPORT_WATER; }
debug_inline static bool IsRailTT() { return TT() == TRANSPORT_RAIL; }
inline bool IsTram() const { return IsRoadTT() && RoadTypeIsTram(RoadVehicle::From(m_veh)->roadtype); }
inline static bool IsRoadTT() { return TT() == TRANSPORT_ROAD; }
debug_inline static bool IsRoadTT() { return TT() == TRANSPORT_ROAD; }
inline static bool Allow90degTurns() { return T90deg_turns_allowed_; }
inline static bool DoTrackMasking() { return Tmask_reserved_tracks; }

@ -831,7 +831,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
/* Disallow breaking end-of-line of someone else
* so trams can still reverse on this tile. */
if (Company::IsValidID(tram_owner) && HasExactlyOneBit(tram)) {
CommandCost ret = CheckOwnership(tram_owner);
ret = CheckOwnership(tram_owner);
if (ret.Failed()) return ret;
}

@ -39,6 +39,7 @@
#include "tracerestrict.h"
#include "programmable_signals.h"
#include "newgrf_newsignals.h"
#include "core/backup_type.hpp"
#include "station_map.h"
#include "tunnelbridge_map.h"
@ -1399,28 +1400,24 @@ public:
case WID_BRAS_PLATFORM_DIR_X:
/* Set up a clipping area for the '/' station preview */
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
if (!DrawStationTile(x, y, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
}
_cur_dpi = old_dpi;
}
break;
case WID_BRAS_PLATFORM_DIR_Y:
/* Set up a clipping area for the '\' station preview */
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
if (!DrawStationTile(x, y, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
}
_cur_dpi = old_dpi;
}
break;
@ -1450,14 +1447,12 @@ public:
/* Set up a clipping area for the station preview. */
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
if (!DrawStationTile(x, y, _cur_railtype, _railstation.orientation, _railstation.station_class, type)) {
StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation);
}
_cur_dpi = old_dpi;
}
break;
}
@ -2302,12 +2297,10 @@ struct BuildRailDepotWindow : public PickerWindowBase {
DrawPixelInfo tmp_dpi;
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
DrawTrainDepotSprite(x, y, widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
_cur_dpi = old_dpi;
}
}
@ -2414,12 +2407,10 @@ struct BuildRailWaypointWindow : PickerWindowBase {
DrawPixelInfo tmp_dpi;
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
DrawWaypointSprite(x, y, type, _cur_railtype);
_cur_dpi = old_dpi;
}
if (!IsStationAvailable(statspec)) {

@ -34,7 +34,7 @@ enum RailTileType {
* @pre IsTileType(t, MP_RAILWAY)
* @return the RailTileType
*/
static inline RailTileType GetRailTileType(TileIndex t)
debug_inline static RailTileType GetRailTileType(TileIndex t)
{
dbg_assert_tile(IsTileType(t, MP_RAILWAY), t);
return (RailTileType)GB(_m[t].m5, 6, 2);
@ -47,7 +47,7 @@ static inline RailTileType GetRailTileType(TileIndex t)
* @pre IsTileType(t, MP_RAILWAY)
* @return true if and only if the tile is normal rail (with or without signals)
*/
static inline bool IsPlainRail(TileIndex t)
debug_inline static bool IsPlainRail(TileIndex t)
{
RailTileType rtt = GetRailTileType(t);
return rtt == RAIL_TILE_NORMAL || rtt == RAIL_TILE_SIGNALS;
@ -58,7 +58,7 @@ static inline bool IsPlainRail(TileIndex t)
* @param t the tile to get the information from
* @return true if and only if the tile is normal rail (with or without signals)
*/
static inline bool IsPlainRailTile(TileIndex t)
debug_inline static bool IsPlainRailTile(TileIndex t)
{
return IsTileType(t, MP_RAILWAY) && IsPlainRail(t);
}
@ -93,7 +93,7 @@ static inline void SetHasSignals(TileIndex tile, bool signals)
* @pre IsTileType(t, MP_RAILWAY)
* @return true if and only if the tile is a rail depot
*/
static inline bool IsRailDepot(TileIndex t)
debug_inline static bool IsRailDepot(TileIndex t)
{
return GetRailTileType(t) == RAIL_TILE_DEPOT;
}
@ -103,7 +103,7 @@ static inline bool IsRailDepot(TileIndex t)
* @param t the tile to get the information from
* @return true if and only if the tile is a rail depot
*/
static inline bool IsRailDepotTile(TileIndex t)
debug_inline static bool IsRailDepotTile(TileIndex t)
{
return IsTileType(t, MP_RAILWAY) && IsRailDepot(t);
}

@ -2282,7 +2282,7 @@ static void DrawTile_Road(TileInfo *ti, DrawTileProcParams params)
/* Draw rail/PBS overlay */
bool draw_pbs = _game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile);
if (rti->UsesOverlay()) {
PaletteID pal = draw_pbs ? PALETTE_CRASH : PAL_NONE;
pal = draw_pbs ? PALETTE_CRASH : PAL_NONE;
SpriteID rail = GetCustomRailSprite(rti, ti->tile, RTSG_CROSSING) + axis;
DrawGroundSprite(rail, pal);
@ -2329,7 +2329,7 @@ static void DrawTile_Road(TileInfo *ti, DrawTileProcParams params)
}
} else if (draw_pbs || tram_rti != nullptr || road_rti->UsesOverlay()) {
/* Add another rail overlay, unless there is only the base road sprite. */
PaletteID pal = draw_pbs ? PALETTE_CRASH : PAL_NONE;
pal = draw_pbs ? PALETTE_CRASH : PAL_NONE;
SpriteID rail = GetCrossingRoadAxis(ti->tile) == AXIS_Y ? GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_x : GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_y;
DrawGroundSprite(rail, pal);
}

@ -40,6 +40,7 @@
#include "sortlist_type.h"
#include "stringfilter_type.h"
#include "string_func.h"
#include "core/backup_type.hpp"
#include "widgets/road_widget.h"
#include "table/strings.h"
@ -1139,12 +1140,10 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
DrawPixelInfo tmp_dpi;
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
DrawRoadDepotSprite(x, y, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
_cur_dpi = old_dpi;
}
}
@ -1564,8 +1563,7 @@ public:
bool disabled = (spec != nullptr && widget < WID_BROS_STATION_X && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY));
DrawPixelInfo tmp_dpi;
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
if (spec != nullptr && spec->height > 2) y += (spec->height - 2) * ScaleSpriteTrad(4);
@ -1575,7 +1573,6 @@ public:
} else {
DrawRoadStopTile(x, y, _cur_roadtype, spec, st, widget - WID_BROS_STATION_NE);
}
_cur_dpi = old_dpi;
}
break;
}
@ -1607,8 +1604,7 @@ public:
}
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
if (spec == nullptr) {
@ -1618,7 +1614,6 @@ public:
if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
DrawRoadStopTile(x, y, _cur_roadtype, spec, st, (uint8)orientation);
}
_cur_dpi = old_dpi;
}
break;
}

@ -52,7 +52,7 @@ static inline bool MayHaveRoad(TileIndex t)
* @pre IsTileType(t, MP_ROAD)
* @return The road tile type.
*/
static inline RoadTileType GetRoadTileType(TileIndex t)
debug_inline static RoadTileType GetRoadTileType(TileIndex t)
{
dbg_assert_tile(IsTileType(t, MP_ROAD), t);
return (RoadTileType)GB(_m[t].m5, 6, 2);
@ -64,7 +64,7 @@ static inline RoadTileType GetRoadTileType(TileIndex t)
* @pre IsTileType(t, MP_ROAD)
* @return True if normal road.
*/
static inline bool IsNormalRoad(TileIndex t)
debug_inline static bool IsNormalRoad(TileIndex t)
{
return GetRoadTileType(t) == ROAD_TILE_NORMAL;
}
@ -74,7 +74,7 @@ static inline bool IsNormalRoad(TileIndex t)
* @param t Tile to query.
* @return True if normal road tile.
*/
static inline bool IsNormalRoadTile(TileIndex t)
debug_inline static bool IsNormalRoadTile(TileIndex t)
{
return IsTileType(t, MP_ROAD) && IsNormalRoad(t);
}
@ -106,7 +106,7 @@ static inline bool IsLevelCrossingTile(TileIndex t)
* @pre IsTileType(t, MP_ROAD)
* @return True if road depot.
*/
static inline bool IsRoadDepot(TileIndex t)
debug_inline static bool IsRoadDepot(TileIndex t)
{
return GetRoadTileType(t) == ROAD_TILE_DEPOT;
}
@ -116,7 +116,7 @@ static inline bool IsRoadDepot(TileIndex t)
* @param t Tile to query.
* @return True if road depot tile.
*/
static inline bool IsRoadDepotTile(TileIndex t)
debug_inline static bool IsRoadDepotTile(TileIndex t)
{
return IsTileType(t, MP_ROAD) && IsRoadDepot(t);
}

@ -8,6 +8,7 @@
/** @file roadveh_gui.cpp GUI for road vehicles. */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "roadveh.h"
#include "window_gui.h"
#include "strings_func.h"
@ -136,13 +137,12 @@ void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, Engi
Direction dir = rtl ? DIR_E : DIR_W;
const RoadVehicle *u = RoadVehicle::From(v);
DrawPixelInfo tmp_dpi, *old_dpi;
DrawPixelInfo tmp_dpi;
int max_width = r.Width();
if (!FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) return;
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int px = rtl ? max_width + skip : -skip;
int y = r.Height() / 2;
@ -161,8 +161,6 @@ void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, Engi
px += rtl ? -width : width;
}
_cur_dpi = old_dpi;
if (v->index == selection) {
int height = ScaleSpriteTrad(12);
Rect hr = {(rtl ? px : 0), 0, (rtl ? max_width : px) - 1, height - 1};

@ -385,11 +385,13 @@ static bool FixTTOEngines()
}
/* Load the default engine set. Many of them will be overridden later */
uint j = 0;
for (uint i = 0; i < lengthof(_orig_rail_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_TRAIN, i);
for (uint i = 0; i < lengthof(_orig_road_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_ROAD, i);
for (uint i = 0; i < lengthof(_orig_ship_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_SHIP, i);
for (uint i = 0; i < lengthof(_orig_aircraft_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_AIRCRAFT, i);
{
uint j = 0;
for (uint i = 0; i < lengthof(_orig_rail_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_TRAIN, i);
for (uint i = 0; i < lengthof(_orig_road_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_ROAD, i);
for (uint i = 0; i < lengthof(_orig_ship_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_SHIP, i);
for (uint i = 0; i < lengthof(_orig_aircraft_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_AIRCRAFT, i);
}
Date aging_date = std::min(_date + DAYS_TILL_ORIGINAL_BASE_YEAR, ConvertYMDToDate(2050, 0, 1));

@ -1697,26 +1697,26 @@ std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt)
DEBUG(sl, _sl.action == SLA_LOAD ? 2 : 6, "Field '%s' of type 0x%02X not found, skipping", key.c_str(), type);
std::shared_ptr<SaveLoadHandler> handler = nullptr;
SaveLoadType slt;
SaveLoadType saveload_type;
switch (type & SLE_FILE_TYPE_MASK) {
case SLE_FILE_STRING:
/* Strings are always marked with SLE_FILE_HAS_LENGTH_FIELD, as they are a list of chars. */
slt = SL_STR;
saveload_type = SL_STR;
break;
case SLE_FILE_STRUCT:
/* Structs are always marked with SLE_FILE_HAS_LENGTH_FIELD as SL_STRUCT is seen as a list of 0/1 in length. */
slt = SL_STRUCTLIST;
saveload_type = SL_STRUCTLIST;
handler = std::make_shared<SlSkipHandler>();
break;
default:
slt = (type & SLE_FILE_HAS_LENGTH_FIELD) ? SL_ARR : SL_VAR;
saveload_type = (type & SLE_FILE_HAS_LENGTH_FIELD) ? SL_ARR : SL_VAR;
break;
}
/* We don't know this field, so read to nothing. */
saveloads.push_back({key, slt, ((VarType)type & SLE_FILE_TYPE_MASK) | SLE_VAR_NULL, 1, SL_MIN_VERSION, SL_MAX_VERSION, 0, nullptr, 0, handler});
saveloads.push_back({key, saveload_type, ((VarType)type & SLE_FILE_TYPE_MASK) | SLE_VAR_NULL, 1, SL_MIN_VERSION, SL_MAX_VERSION, 0, nullptr, 0, handler});
continue;
}

@ -8,6 +8,7 @@
/** @file screenshot.cpp The creation of screenshots! */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "fileio_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
@ -635,7 +636,7 @@ static void CurrentScreenCallback(void *userdata, void *buf, uint y, uint pitch,
static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
{
Viewport *vp = (Viewport *)userdata;
DrawPixelInfo dpi, *old_dpi;
DrawPixelInfo dpi;
int wx, left;
/* We are no longer rendering to the screen */
@ -648,8 +649,7 @@ static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, ui
_screen.pitch = pitch;
_screen_disable_anim = true;
old_dpi = _cur_dpi;
_cur_dpi = &dpi;
Backup dpi_backup(_cur_dpi, &dpi, FILE_LINE);
dpi.dst_ptr = buf;
dpi.height = n;
@ -674,7 +674,7 @@ static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, ui
);
}
_cur_dpi = old_dpi;
dpi_backup.Restore();
ViewportDoDrawProcessAllPending();

@ -8,6 +8,7 @@
/** @file smallmap_gui.cpp GUI that shows a small map of the world with metadata like owner or height. */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "clear_map.h"
#include "industry.h"
#include "station_map.h"
@ -955,10 +956,7 @@ void SmallMapWindow::DrawMapIndicators() const
void SmallMapWindow::DrawSmallMap(DrawPixelInfo *dpi, bool draw_indicators) const
{
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
DrawPixelInfo *old_dpi;
old_dpi = _cur_dpi;
_cur_dpi = dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, dpi);
/* Clear it */
GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, PC_BLACK);
@ -1017,8 +1015,6 @@ void SmallMapWindow::DrawSmallMap(DrawPixelInfo *dpi, bool draw_indicators) cons
/* Draw map indicators */
if (draw_indicators) this->DrawMapIndicators();
_cur_dpi = old_dpi;
}
/**

@ -1176,7 +1176,7 @@ CommandCost CheckFlatLandRoadStop(TileArea tile_area, const RoadStopSpec *spec,
if (road_owner == OWNER_TOWN) {
if (!_settings_game.construction.road_stop_on_town_road) return_cmd_error(STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD);
} else if (!_settings_game.construction.road_stop_on_competitor_road && road_owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(road_owner);
ret = CheckOwnership(road_owner);
if (ret.Failed()) return ret;
}
uint num_pieces = CountBits(GetRoadBits(cur_tile, RTT_ROAD));
@ -1197,7 +1197,7 @@ CommandCost CheckFlatLandRoadStop(TileArea tile_area, const RoadStopSpec *spec,
/* Disallow breaking end-of-line of someone else
* so trams can still reverse on this tile. */
HasExactlyOneBit(GetRoadBits(cur_tile, RTT_TRAM)))) {
CommandCost ret = CheckOwnership(tram_owner);
ret = CheckOwnership(tram_owner);
if (ret.Failed()) return ret;
}
uint num_pieces = CountBits(GetRoadBits(cur_tile, RTT_TRAM));
@ -1550,7 +1550,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
if (ret.Failed()) return ret;
if (st != nullptr && st->train_station.tile != INVALID_TILE) {
CommandCost ret = CanExpandRailStation(st, new_location, axis);
ret = CanExpandRailStation(st, new_location, axis);
if (ret.Failed()) return ret;
}
@ -1821,7 +1821,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector<T *> &affected_st
if (st == nullptr) continue;
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner);
ret = CheckOwnership(st->owner);
error.AddCost(ret);
if (ret.Failed()) continue;
}
@ -3522,7 +3522,6 @@ draw_default_foundation:
/* PBS debugging, draw reserved tracks darker */
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasStationRail(ti->tile) && HasStationReservation(ti->tile)) {
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
DrawGroundSprite(GetRailStationAxis(ti->tile) == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH);
}
}
@ -3605,17 +3604,17 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro
int32 total_offset = 0;
PaletteID pal = COMPANY_SPRITE_COLOUR(_local_company);
const DrawTileSprites *t = GetStationTileLayout(st, image);
const RailtypeInfo *rti = nullptr;
const RailtypeInfo *railtype_info = nullptr;
if (railtype != INVALID_RAILTYPE) {
rti = GetRailTypeInfo(railtype);
total_offset = rti->GetRailtypeSpriteOffset();
railtype_info = GetRailTypeInfo(railtype);
total_offset = railtype_info->GetRailtypeSpriteOffset();
}
SpriteID img = t->ground.sprite;
RailTrackOffset overlay_offset;
if (rti != nullptr && rti->UsesOverlay() && SplitGroundSpriteForOverlay(nullptr, &img, &overlay_offset)) {
SpriteID ground = GetCustomRailSprite(rti, INVALID_TILE, RTSG_GROUND);
if (railtype_info != nullptr && railtype_info->UsesOverlay() && SplitGroundSpriteForOverlay(nullptr, &img, &overlay_offset)) {
SpriteID ground = GetCustomRailSprite(railtype_info, INVALID_TILE, RTSG_GROUND);
DrawSprite(img, PAL_NONE, x, y);
DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
} else {
@ -3623,25 +3622,25 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro
}
if (roadtype != INVALID_ROADTYPE) {
const RoadTypeInfo* rti = GetRoadTypeInfo(roadtype);
const RoadTypeInfo *roadtype_info = GetRoadTypeInfo(roadtype);
if (image >= 4) {
/* Drive-through stop */
uint sprite_offset = 5 - image;
/* Road underlay takes precedence over tram */
if (rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND);
if (roadtype_info->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_GROUND);
DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
SpriteID overlay = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_OVERLAY);
SpriteID overlay = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_OVERLAY);
if (overlay) DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
} else if (RoadTypeIsTram(roadtype)) {
DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
}
} else {
/* Drive-in stop */
if (RoadTypeIsRoad(roadtype) && rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_ROADSTOP);
if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(roadtype_info, INVALID_TILE, ROTSG_ROADSTOP);
DrawSprite(ground + image, PAL_NONE, x, y);
}
}

@ -8,6 +8,7 @@
/** @file statusbar_gui.cpp The GUI for the bottom status bar. */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "date_func.h"
#include "gfx_func.h"
#include "news_func.h"
@ -68,10 +69,8 @@ static bool DrawScrollingStatusText(const NewsItem *ni, int scroll_pos, int left
int width = GetStringBoundingBox(buffer).width;
int pos = (_current_text_dir == TD_RTL) ? (scroll_pos - width) : (right - scroll_pos - left);
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
DrawString(pos, INT16_MAX, 0, buffer, TC_LIGHT_BLUE, SA_LEFT | SA_FORCE);
_cur_dpi = old_dpi;
return (_current_text_dir == TD_RTL) ? (pos < right - left) : (pos + width > 0);
}

@ -334,6 +334,51 @@
#define OTTD_PRINTFHEX64 "%" OTTD_PRINTFHEX64_SUFFIX
#define OTTD_PRINTFHEX64PAD "%016" OTTD_PRINTFHEX64_SUFFIX
/*
* When making a (pure) debug build, the compiler will by default disable
* inlining of functions. This has a detremental effect on the performance of
* debug builds, especially when more and more trivial (wrapper) functions get
* added to the code base.
* Take for example the savegame called "Wentbourne", when running this game
* for 100 ticks with the null video driver a number of fairly trivial
* functions show up on top. The most common one is the implicit conversion
* operator of TileIndex to unsigned int, which takes up over 5% of the total
* run time and functionally does absolutely nothing. The remaining functions
* for the top 5 are GB, GetTileType, Map::Size and IsTileType to a total of
* about 12.5% of the game's total run time.
* It is possible to still force inlining in the most commonly used compilers,
* but that is at the cost of some problems with debugging due to the forced
* inlining. However, the performance benefit can be enormous; when forcing
* inlining for the previously mentioned top 5, the debug build ran about 15%
* quicker.
* The following debug_inline annotation may be added to functions comply
* with the following preconditions:
* 1: the function takes more than 0.5% of a profiled debug runtime
* 2: the function does not modify the game state
* 3: the function does not contain selection or iteration statements,
* i.e. no if, switch, for, do, while, etcetera.
* 4: the function is one line of code, excluding assertions.
* 5: the function is defined in a header file.
* The debug_inline annotation must be placed in front of the function, i.e.
* before the optional static or constexpr modifier.
*/
#if !defined(_DEBUG) || defined(NO_DEBUG_INLINE)
/*
* Do not force inlining when not in debug. This way we do not work against
* any carefully designed compiler optimizations.
*/
#define debug_inline inline
#elif defined(__clang__) || defined(__GNUC__)
#define debug_inline [[gnu::always_inline]] inline
#else
/*
* MSVC explicitly disables inlining, even forced inlining, in debug builds
* so __forceinline makes no difference compared to inline. Other unknown
* compilers can also just fallback to a normal inline.
*/
#define debug_inline inline
#endif
typedef unsigned char byte;
/* This is already defined in unix, but not in QNX Neutrino (6.x) or Cygwin. */

@ -25,6 +25,7 @@
#include "company_base.h"
#include "tilehighlight_func.h"
#include "vehicle_base.h"
#include "core/backup_type.hpp"
#include "widgets/story_widget.h"
@ -697,8 +698,7 @@ public:
DrawPixelInfo tmp_dpi;
if (!FillDrawPixelInfo(&tmp_dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
/* Draw content (now coordinates given to Draw** are local to the new clipping region). */
fr = fr.Translate(-fr.left, -fr.top);
@ -757,9 +757,6 @@ public:
default: NOT_REACHED();
}
}
/* Restore clipping region. */
_cur_dpi = old_dpi;
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override

@ -473,9 +473,9 @@ int CDECL main(int argc, char *argv[])
case 'P':
printf("name\tflags\tdefault\tdescription\n");
for (size_t i = 0; i < lengthof(_pragmas); i++) {
for (size_t j = 0; j < lengthof(_pragmas); j++) {
printf("\"%s\"\t%s\t\"%s\"\t\"%s\"\n",
_pragmas[i][0], _pragmas[i][1], _pragmas[i][2], _pragmas[i][3]);
_pragmas[j][0], _pragmas[j][1], _pragmas[j][2], _pragmas[j][3]);
}
return 0;

@ -878,7 +878,7 @@ static int TranslateArgumentIdx(int argidx, int offset)
}
for (int i = sum = 0; i < argidx; i++) {
const CmdStruct *cs = _cur_pcs.cmd[i];
cs = _cur_pcs.cmd[i];
sum += (cs != nullptr) ? cs->consumes : 1;
}

@ -1296,19 +1296,19 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
case SCC_RAW_STRING_POINTER: { // {RAW_STRING}
if (game_script) break;
const char *str = (const char *)(size_t)args->GetInt64(SCC_RAW_STRING_POINTER);
buff = FormatString(buff, str, args, last);
const char *raw_string = (const char *)(size_t)args->GetInt64(SCC_RAW_STRING_POINTER);
buff = FormatString(buff, raw_string, args, last);
break;
}
case SCC_STRING: {// {STRING}
StringID str = args->GetInt32(SCC_STRING);
if (game_script && GetStringTab(str) != TEXT_TAB_GAMESCRIPT_START) break;
StringID string_id = args->GetInt32(SCC_STRING);
if (game_script && GetStringTab(string_id) != TEXT_TAB_GAMESCRIPT_START) break;
/* WARNING. It's prohibited for the included string to consume any arguments.
* For included strings that consume argument, you should use STRING1, STRING2 etc.
* To debug stuff you can set argv to nullptr and it will tell you */
StringParameters tmp_params(args->GetDataPointer(), args->GetDataLeft(), nullptr);
buff = GetStringWithArgs(buff, str, &tmp_params, last, next_substr_case_index, game_script);
buff = GetStringWithArgs(buff, string_id, &tmp_params, last, next_substr_case_index, game_script);
next_substr_case_index = 0;
break;
}
@ -1322,14 +1322,14 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
case SCC_STRING7:
case SCC_STRING8: { // {STRING1..8}
/* Strings that consume arguments */
StringID str = args->GetInt32(b);
if (game_script && GetStringTab(str) != TEXT_TAB_GAMESCRIPT_START) break;
StringID string_id = args->GetInt32(b);
if (game_script && GetStringTab(string_id) != TEXT_TAB_GAMESCRIPT_START) break;
uint size = b - SCC_STRING1 + 1;
if (game_script && size > args->GetDataLeft()) {
buff = strecat(buff, "(too many parameters)", last);
} else {
StringParameters sub_args(*args, size);
buff = GetStringWithArgs(buff, str, &sub_args, last, next_substr_case_index, game_script);
buff = GetStringWithArgs(buff, string_id, &sub_args, last, next_substr_case_index, game_script);
}
next_substr_case_index = 0;
break;
@ -1835,7 +1835,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
StringID str = st->string_id;
StringID string_id = st->string_id;
if (st->indtype != IT_INVALID) {
/* Special case where the industry provides the name for the station */
const IndustrySpec *indsp = GetIndustrySpec(st->indtype);
@ -1844,17 +1844,17 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
* thus cause very strange things. Here we check for that before we
* actually set the station name. */
if (indsp->station_name != STR_NULL && indsp->station_name != STR_UNDEFINED) {
str = indsp->station_name;
string_id = indsp->station_name;
}
}
if (st->extra_name_index != UINT16_MAX && st->extra_name_index < _extra_station_names_used) {
str = _extra_station_names[st->extra_name_index].str;
string_id = _extra_station_names[st->extra_name_index].str;
}
uint64 args_array[] = {STR_TOWN_NAME, st->town->index, st->index};
WChar types_array[] = {0, SCC_TOWN_NAME, SCC_NUM};
StringParameters tmp_params(args_array, 3, types_array);
buff = GetStringWithArgs(buff, str, &tmp_params, last);
buff = GetStringWithArgs(buff, string_id, &tmp_params, last);
}
break;
}
@ -1884,9 +1884,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
} else {
int64 args_array[] = {wp->town->index, wp->town_cn + 1};
StringParameters tmp_params(args_array);
StringID str = ((wp->string_id == STR_SV_STNAME_BUOY) ? STR_FORMAT_BUOY_NAME : STR_FORMAT_WAYPOINT_NAME);
if (wp->town_cn != 0) str++;
buff = GetStringWithArgs(buff, str, &tmp_params, last);
StringID string_id = ((wp->string_id == STR_SV_STNAME_BUOY) ? STR_FORMAT_BUOY_NAME : STR_FORMAT_WAYPOINT_NAME);
if (wp->town_cn != 0) string_id++;
buff = GetStringWithArgs(buff, string_id, &tmp_params, last);
}
break;
}
@ -1916,14 +1916,14 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
int64 args_array[] = {v->unitnumber};
StringParameters tmp_params(args_array);
StringID str;
StringID string_id;
if (v->type < VEH_COMPANY_END) {
str = ((_settings_client.gui.vehicle_names == 1) ? STR_SV_TRAIN_NAME : STR_TRADITIONAL_TRAIN_NAME) + v->type;
string_id = ((_settings_client.gui.vehicle_names == 1) ? STR_SV_TRAIN_NAME : STR_TRADITIONAL_TRAIN_NAME) + v->type;
} else {
str = STR_INVALID_VEHICLE;
string_id = STR_INVALID_VEHICLE;
}
buff = GetStringWithArgs(buff, str, &tmp_params, last);
buff = GetStringWithArgs(buff, string_id, &tmp_params, last);
}
break;
}

@ -8,6 +8,7 @@
/** @file textfile_gui.cpp Implementation of textfile window. */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "fileio_func.h"
#include "fontcache.h"
#include "gfx_type.h"
@ -152,8 +153,7 @@ void TextfileWindow::SetupScrollbars(bool force_reflow)
DrawPixelInfo new_dpi;
if (!FillDrawPixelInfo(&new_dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &new_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &new_dpi);
/* Draw content (now coordinates given to DrawString* are local to the new clipping region). */
fr = fr.Translate(-fr.left, -fr.top);
@ -172,8 +172,6 @@ void TextfileWindow::SetupScrollbars(bool force_reflow)
DrawString(-this->hscroll->GetPosition(), fr.right, y_offset, line.text, TC_BLACK, SA_TOP | SA_LEFT, false, FS_MONO);
}
}
_cur_dpi = old_dpi;
}
/* virtual */ void TextfileWindow::OnResize()

@ -26,7 +26,7 @@
* @return the height of the tile
* @pre tile < MapSize()
*/
static inline uint TileHeight(TileIndex tile)
debug_inline static uint TileHeight(TileIndex tile)
{
/* this method is inlined in many places and is performance-critical, drop assertion in non-debug builds */
#ifdef _DEBUG
@ -96,7 +96,7 @@ static inline uint TilePixelHeightOutsideMap(int x, int y)
* @return The tiletype of the tile
* @pre tile < MapSize()
*/
static inline TileType GetTileType(TileIndex tile)
debug_inline static TileType GetTileType(TileIndex tile)
{
/* this method is inlined in many places and is performance-critical, drop assertion in non-debug builds */
#ifdef _DEBUG
@ -153,7 +153,7 @@ static inline void SetTileType(TileIndex tile, TileType type)
* @param type The type to check against
* @return true If the type matches against the type of the tile
*/
static inline bool IsTileType(TileIndex tile, TileType type)
debug_inline static bool IsTileType(TileIndex tile, TileType type)
{
return GetTileType(tile) == type;
}

@ -124,16 +124,16 @@ static void FillTimetableArrivalDepartureTable(const Vehicle *v, VehicleOrderID
assert(v->GetNumOrders() >= 2);
assert(start < v->GetNumOrders());
Ticks sum = offset;
VehicleOrderID i = start;
const Order *order = v->GetOrder(i);
/* Pre-initialize with unknown time */
for (int i = 0; i < v->GetNumOrders(); ++i) {
table[i].arrival = table[i].departure = INVALID_TICKS;
table[i].flags = 0;
}
Ticks sum = offset;
VehicleOrderID i = start;
const Order *order = v->GetOrder(i);
bool predicted = false;
bool no_offset = false;
bool skip_travel = false;

@ -99,7 +99,7 @@ static bool TestTownOwnsBridge(TileIndex tile, const Town *t)
if (!town_owned) {
/* Or other adjacent road */
TileIndex adjacent = tile + TileOffsByDiagDir(ReverseDiagDir(GetTunnelBridgeDirection(GetOtherTunnelBridgeEnd(tile))));
adjacent = tile + TileOffsByDiagDir(ReverseDiagDir(GetTunnelBridgeDirection(GetOtherTunnelBridgeEnd(tile))));
town_owned = IsTileType(adjacent, MP_ROAD) && IsTileOwner(adjacent, OWNER_TOWN) && GetTownIndex(adjacent) == t->index;
}

@ -2157,7 +2157,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
/* If the autoreplace flag is set we do not need to test for the validity
* because we are going to revert the train to its original state. As we
* assume the original state was correct autoreplace can skip this. */
CommandCost ret = ValidateTrains(original_dst_head, dst_head, original_src_head, src_head, true);
ret = ValidateTrains(original_dst_head, dst_head, original_src_head, src_head, true);
if (ret.Failed()) {
/* Restore the train we had. */
RestoreTrainBackup(original_src);

@ -14,6 +14,7 @@
#include "strings_func.h"
#include "vehicle_func.h"
#include "zoom_func.h"
#include "core/backup_type.hpp"
#include "table/strings.h"
@ -100,7 +101,7 @@ void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineIm
bool rtl = _current_text_dir == TD_RTL;
Direction dir = rtl ? DIR_E : DIR_W;
DrawPixelInfo tmp_dpi, *old_dpi;
DrawPixelInfo tmp_dpi;
/* Position of highlight box */
int highlight_l = 0;
int highlight_r = 0;
@ -108,56 +109,55 @@ void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineIm
if (!FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) return;
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
int px = rtl ? max_width + skip : -skip;
int y = r.Height() / 2;
bool sel_articulated = false;
bool dragging = (drag_dest != INVALID_VEHICLE);
bool drag_at_end_of_train = (drag_dest == v->index); // Head index is used to mark dragging at end of train.
for (; v != nullptr && (rtl ? px > 0 : px < max_width); v = v->Next()) {
if (dragging && !drag_at_end_of_train && drag_dest == v->index) {
/* Highlight the drag-and-drop destination inside the train. */
int drag_hlight_width = HighlightDragPosition(px, max_width, y, selection, _cursor.vehchain);
px += rtl ? -drag_hlight_width : drag_hlight_width;
}
{
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
int px = rtl ? max_width + skip : -skip;
int y = r.Height() / 2;
bool sel_articulated = false;
bool dragging = (drag_dest != INVALID_VEHICLE);
bool drag_at_end_of_train = (drag_dest == v->index); // Head index is used to mark dragging at end of train.
for (; v != nullptr && (rtl ? px > 0 : px < max_width); v = v->Next()) {
if (dragging && !drag_at_end_of_train && drag_dest == v->index) {
/* Highlight the drag-and-drop destination inside the train. */
int drag_hlight_width = HighlightDragPosition(px, max_width, y, selection, _cursor.vehchain);
px += rtl ? -drag_hlight_width : drag_hlight_width;
}
Point offset;
int width = Train::From(v)->GetDisplayImageWidth(&offset);
Point offset;
int width = Train::From(v)->GetDisplayImageWidth(&offset);
if (rtl ? px + width > 0 : px - width < max_width) {
PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
VehicleSpriteSeq seq;
v->GetImage(dir, image_type, &seq);
seq.Draw(px + (rtl ? -offset.x : offset.x), y + offset.y, pal, (v->vehstatus & VS_CRASHED) != 0);
}
if (rtl ? px + width > 0 : px - width < max_width) {
PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
VehicleSpriteSeq seq;
v->GetImage(dir, image_type, &seq);
seq.Draw(px + (rtl ? -offset.x : offset.x), y + offset.y, pal, (v->vehstatus & VS_CRASHED) != 0);
}
if (!v->IsArticulatedPart()) sel_articulated = false;
if (!v->IsArticulatedPart()) sel_articulated = false;
if (v->index == selection) {
/* Set the highlight position */
highlight_l = rtl ? px - width : px;
highlight_r = rtl ? px - 1 : px + width - 1;
sel_articulated = true;
} else if ((_cursor.vehchain && highlight_r != 0) || sel_articulated) {
if (rtl) {
highlight_l -= width;
} else {
highlight_r += width;
if (v->index == selection) {
/* Set the highlight position */
highlight_l = rtl ? px - width : px;
highlight_r = rtl ? px - 1 : px + width - 1;
sel_articulated = true;
} else if ((_cursor.vehchain && highlight_r != 0) || sel_articulated) {
if (rtl) {
highlight_l -= width;
} else {
highlight_r += width;
}
}
}
px += rtl ? -width : width;
}
px += rtl ? -width : width;
}
if (dragging && drag_at_end_of_train) {
/* Highlight the drag-and-drop destination at the end of the train. */
HighlightDragPosition(px, max_width, y, selection, _cursor.vehchain);
if (dragging && drag_at_end_of_train) {
/* Highlight the drag-and-drop destination at the end of the train. */
HighlightDragPosition(px, max_width, y, selection, _cursor.vehchain);
}
}
_cur_dpi = old_dpi;
if (highlight_l != highlight_r) {
/* Draw the highlight. Now done after drawing all the engines, as
* the next engine after the highlight could overlap it. */

@ -1222,7 +1222,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
/* Check if you are allowed to remove the tunnel owned by a town
* Removal depends on difficulty settings */
CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
if (ret.Failed()) return ret;
}
@ -1345,7 +1345,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
/* Check if you are allowed to remove the bridge owned by a town
* Removal depends on difficulty settings */
CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
if (ret.Failed()) return ret;
}

@ -573,7 +573,7 @@ public:
* Check if the vehicle is a ground vehicle.
* @return True iff the vehicle is a train or a road vehicle.
*/
inline bool IsGroundVehicle() const
debug_inline bool IsGroundVehicle() const
{
return this->type == VEH_TRAIN || this->type == VEH_ROAD;
}
@ -1059,7 +1059,7 @@ public:
* Check if the vehicle is a front engine.
* @return Returns true if the vehicle is a front engine.
*/
inline bool IsFrontEngine() const
debug_inline bool IsFrontEngine() const
{
return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_FRONT);
}

@ -4064,8 +4064,8 @@ public:
}
/* The same system applies to widget WID_VV_REFIT_VEH and VVW_WIDGET_TURN_AROUND.*/
if (v->IsGroundVehicle()) {
PlaneSelections plane = veh_stopped ? SEL_RT_REFIT : SEL_RT_TURN_AROUND;
NWidgetStacked *nwi = this->GetWidget<NWidgetStacked>(WID_VV_SELECT_REFIT_TURN);
plane = veh_stopped ? SEL_RT_REFIT : SEL_RT_TURN_AROUND;
nwi = this->GetWidget<NWidgetStacked>(WID_VV_SELECT_REFIT_TURN);
if (nwi->shown_plane + SEL_RT_BASEPLANE != plane) {
this->SelectPlane(plane);
this->SetWidgetDirty(WID_VV_SELECT_REFIT_TURN);

@ -1120,8 +1120,8 @@ void OpenGLBackend::PopulateCursorCache()
if (!this->cursor_cache.Contains(sprite)) {
Sprite *old = this->cursor_cache.Insert(sprite, (Sprite *)GetRawSprite(sprite, ST_NORMAL, &SimpleSpriteAlloc, this));
if (old != nullptr) {
OpenGLSprite *sprite = (OpenGLSprite *)old->data;
sprite->~OpenGLSprite();
OpenGLSprite *gl_sprite = (OpenGLSprite *)old->data;
gl_sprite->~OpenGLSprite();
free(old);
}
}

@ -1826,9 +1826,6 @@ static void ViewportAddKdtreeSigns(ViewportDrawerDynamic *vdd, DrawPixelInfo *dp
bool show_competitors = HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS) && !towns_only;
bool hide_hidden_waypoints = _settings_client.gui.allow_hiding_waypoint_labels && !HasBit(_extra_display_opt, XDO_SHOW_HIDDEN_SIGNS);
const BaseStation *st;
const Sign *si;
/* Collect all the items first and draw afterwards, to ensure layering */
std::vector<const BaseStation *> stations;
std::vector<const Town *> towns;
@ -1836,19 +1833,20 @@ static void ViewportAddKdtreeSigns(ViewportDrawerDynamic *vdd, DrawPixelInfo *dp
_viewport_sign_kdtree.FindContained(search_rect.left, search_rect.top, search_rect.right, search_rect.bottom, [&](const ViewportSignKdtreeItem & item) {
switch (item.type) {
case ViewportSignKdtreeItem::VKI_STATION:
case ViewportSignKdtreeItem::VKI_STATION: {
if (!show_stations) break;
st = BaseStation::Get(item.id.station);
const BaseStation *st = BaseStation::Get(item.id.station);
/* Don't draw if station is owned by another company and competitor station names are hidden. Stations owned by none are never ignored. */
if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break;
stations.push_back(st);
break;
}
case ViewportSignKdtreeItem::VKI_WAYPOINT:
case ViewportSignKdtreeItem::VKI_WAYPOINT: {
if (!show_waypoints) break;
st = BaseStation::Get(item.id.station);
const BaseStation *st = BaseStation::Get(item.id.station);
/* Don't draw if station is owned by another company and competitor station names are hidden. Stations owned by none are never ignored. */
if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break;
@ -1856,15 +1854,16 @@ static void ViewportAddKdtreeSigns(ViewportDrawerDynamic *vdd, DrawPixelInfo *dp
stations.push_back(st);
break;
}
case ViewportSignKdtreeItem::VKI_TOWN:
if (!show_towns) break;
towns.push_back(Town::Get(item.id.town));
break;
case ViewportSignKdtreeItem::VKI_SIGN:
case ViewportSignKdtreeItem::VKI_SIGN: {
if (!show_signs) break;
si = Sign::Get(item.id.sign);
const Sign *si = Sign::Get(item.id.sign);
/* Don't draw if sign is owned by another company and competitor signs should be hidden.
* Note: It is intentional that also signs owned by OWNER_NONE are hidden. Bankrupt
@ -1873,6 +1872,7 @@ static void ViewportAddKdtreeSigns(ViewportDrawerDynamic *vdd, DrawPixelInfo *dp
signs.push_back(si);
break;
}
default:
NOT_REACHED();

@ -8,6 +8,7 @@
/** @file widget.cpp Handling of the default/simple widgets. */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "company_func.h"
#include "window_gui.h"
#include "viewport_func.h"
@ -2058,8 +2059,7 @@ void NWidgetMatrix::FillDirtyWidgets(std::vector<NWidgetBase *> &dirty_widgets)
bool rtl = _current_text_dir == TD_RTL;
DrawPixelInfo tmp_dpi;
if (!FillDrawPixelInfo(&tmp_dpi, this->pos_x + (rtl ? this->pip_post : this->pip_pre), this->pos_y + this->pip_pre, this->current_x - this->pip_pre - this->pip_post, this->current_y - this->pip_pre - this->pip_post)) return;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
/* Get the appropriate offsets so we can draw the right widgets. */
NWidgetCore *child = dynamic_cast<NWidgetCore *>(this->head);
@ -2092,9 +2092,6 @@ void NWidgetMatrix::FillDirtyWidgets(std::vector<NWidgetBase *> &dirty_widgets)
child->Draw(w);
}
}
/* Restore the clipping area. */
_cur_dpi = old_dpi;
}
/**
@ -2911,8 +2908,7 @@ void NWidgetLeaf::Draw(const Window *w)
new_dpi.left += this->pos_x;
new_dpi.top += this->pos_y;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &new_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &new_dpi);
Rect r = this->GetCurrentRect();
@ -3026,8 +3022,6 @@ void NWidgetLeaf::Draw(const Window *w)
if (this->IsDisabled()) {
GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[this->colour & 0xF][2], FILLRECT_CHECKER);
}
_cur_dpi = old_dpi;
}
/**

@ -38,6 +38,7 @@
#include "network/network_func.h"
#include "guitimer_func.h"
#include "news_func.h"
#include "core/backup_type.hpp"
#include "safeguards.h"
@ -255,9 +256,9 @@ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour
/* If we disable a highlight, check all widgets if anyone still has a highlight */
bool valid = false;
for (uint i = 0; i < this->nested_array_size; i++) {
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i);
if (nwid == nullptr) continue;
if (!nwid->IsHighlighted()) continue;
NWidgetBase *child_nwid = this->GetWidget<NWidgetBase>(i);
if (child_nwid == nullptr) continue;
if (!child_nwid->IsHighlighted()) continue;
valid = true;
}
@ -979,9 +980,8 @@ void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom, D
*/
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
{
DrawPixelInfo *old_dpi = _cur_dpi;
DrawPixelInfo bk;
_cur_dpi = &bk;
AutoRestoreBackup dpi_backup(_cur_dpi, &bk);
for (Window *w : Window::IterateFromBack()) {
if (MayBeShown(w) &&
@ -993,7 +993,6 @@ void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
DrawOverlappedWindow(w, std::max(left, w->left), std::max(top, w->top), std::min(right, w->left + w->width), std::min(bottom, w->top + w->height), DOWF_NONE);
}
}
_cur_dpi = old_dpi;
}
static void SetWindowDirtyPending(Window *w)

Loading…
Cancel
Save