1
0
Fork 0

Compare commits

...

3 Commits

Author SHA1 Message Date
translators 01728177e7 Update: Translations from eints
english (us): 3 changes by 2TallTyler
french: 2 changes by Lishouuu
2023-11-04 18:37:37 +00:00
Michael Lutz 071fdab236 Codechange: Replicate cursor screen backup to chat message display, removing explicit memory management.
Incidentally, this makes Blitter::GetBytesPerPixel unneeed.
2023-11-04 16:08:34 +01:00
Peter Nelson bbd64bbe2b
Fix #9545: Crash when all cargo types are disabled. (#11432)
This is not a very useful state, but it's nice to not crash.

Some parts of the game don't (yet) check for cargo types being redefined, that is out-of-scope here.
2023-11-04 14:42:47 +00:00
11 changed files with 14 additions and 19 deletions

View File

@ -48,7 +48,6 @@ public:
Blitter::PaletteAnimation UsePaletteAnimation() override; Blitter::PaletteAnimation UsePaletteAnimation() override;
const char *GetName() override { return "32bpp-anim"; } const char *GetName() override { return "32bpp-anim"; }
int GetBytesPerPixel() override { return 6; }
void PostResize() override; void PostResize() override;
/** /**

View File

@ -30,7 +30,6 @@ public:
size_t BufferSize(uint width, uint height) override; size_t BufferSize(uint width, uint height) override;
void PaletteAnimate(const Palette &palette) override; void PaletteAnimate(const Palette &palette) override;
Blitter::PaletteAnimation UsePaletteAnimation() override; Blitter::PaletteAnimation UsePaletteAnimation() override;
int GetBytesPerPixel() override { return 4; }
/** /**
* Look up the colour in the current palette. * Look up the colour in the current palette.

View File

@ -33,7 +33,6 @@ public:
bool NeedsAnimationBuffer() override; bool NeedsAnimationBuffer() override;
const char *GetName() override { return "40bpp-anim"; } const char *GetName() override { return "40bpp-anim"; }
int GetBytesPerPixel() override { return 5; }
template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);

View File

@ -28,7 +28,6 @@ public:
size_t BufferSize(uint width, uint height) override; size_t BufferSize(uint width, uint height) override;
void PaletteAnimate(const Palette &palette) override; void PaletteAnimate(const Palette &palette) override;
Blitter::PaletteAnimation UsePaletteAnimation() override; Blitter::PaletteAnimation UsePaletteAnimation() override;
int GetBytesPerPixel() override { return 1; }
}; };
#endif /* BLITTER_8BPP_BASE_HPP */ #endif /* BLITTER_8BPP_BASE_HPP */

View File

@ -198,11 +198,6 @@ public:
*/ */
virtual const char *GetName() = 0; virtual const char *GetName() = 0;
/**
* Get how many bytes are needed to store a pixel.
*/
virtual int GetBytesPerPixel() = 0;
/** /**
* Post resize event * Post resize event
*/ */

View File

@ -32,7 +32,6 @@ public:
Blitter::PaletteAnimation UsePaletteAnimation() override { return Blitter::PALETTE_ANIMATION_NONE; }; Blitter::PaletteAnimation UsePaletteAnimation() override { return Blitter::PALETTE_ANIMATION_NONE; };
const char *GetName() override { return "null"; } const char *GetName() override { return "null"; }
int GetBytesPerPixel() override { return 0; }
}; };
/** Factory for the blitter that does nothing. */ /** Factory for the blitter that does nothing. */

View File

@ -363,7 +363,6 @@ protected:
if (this->num_on_x_axis == 0) return; if (this->num_on_x_axis == 0) return;
assert(this->num_on_x_axis > 0); assert(this->num_on_x_axis > 0);
assert(this->num_dataset > 0);
/* draw text strings on the y axis */ /* draw text strings on the y axis */
int64_t y_label = interval.highest; int64_t y_label = interval.highest;
@ -923,6 +922,8 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
return; return;
} }
size->height = FONT_HEIGHT_SMALL + WidgetDimensions::scaled.framerect.Vertical();
for (const CargoSpec *cs : _sorted_standard_cargo_specs) { for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
SetDParam(0, cs->name); SetDParam(0, cs->name);
Dimension d = GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO); Dimension d = GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO);
@ -1077,7 +1078,7 @@ static const NWidgetPart _nested_cargo_payment_rates_widgets[] = {
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0),
NWidget(NWID_SPACER), SetMinimalSize(0, 4), NWidget(NWID_SPACER), SetMinimalSize(0, 4),
NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL),
NWidget(WWT_MATRIX, COLOUR_BROWN, WID_CPR_MATRIX), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR), NWidget(WWT_MATRIX, COLOUR_BROWN, WID_CPR_MATRIX), SetFill(1, 0), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_CPR_MATRIX_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_CPR_MATRIX_SCROLLBAR),
EndContainer(), EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1), NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),

View File

@ -533,6 +533,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :About 'OpenTTD'
STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite aligner STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite aligner
STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Toggle bounding boxes STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Toggle bounding boxes
STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Toggle coloring of dirty blocks STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Toggle coloring of dirty blocks
STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :Toggle widget outlines
# Place in highscore window # Place in highscore window
###length 15 ###length 15
@ -3383,6 +3384,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Save
STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Save the preset to the current selected name STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Save the preset to the current selected name
# NewGRF parameters window # NewGRF parameters window
STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Change base graphics parameters
STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Change NewGRF parameters STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Change NewGRF parameters
STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Close STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Close
STR_NEWGRF_PARAMETERS_RESET :{BLACK}Reset STR_NEWGRF_PARAMETERS_RESET :{BLACK}Reset
@ -5187,6 +5189,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Can't ti
STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Vehicles can only wait at stations STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Vehicles can only wait at stations
STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}This vehicle is not stopping at this station STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}This vehicle is not stopping at this station
STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... timetable is incomplete STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... timetable is incomplete
STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... timetable has not started yet
# Sign related errors # Sign related errors
STR_ERROR_TOO_MANY_SIGNS :{WHITE}... too many signs STR_ERROR_TOO_MANY_SIGNS :{WHITE}... too many signs

View File

@ -3385,6 +3385,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Sauvegar
STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Sauvegarder la présélection sous le nom actuellement sélectionné STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Sauvegarder la présélection sous le nom actuellement sélectionné
# NewGRF parameters window # NewGRF parameters window
STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Modifier les paramètres des graphiques de base
STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Modifier les paramètres NewGRF STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Modifier les paramètres NewGRF
STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Fermer STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Fermer
STR_NEWGRF_PARAMETERS_RESET :{BLACK}Réinitialiser STR_NEWGRF_PARAMETERS_RESET :{BLACK}Réinitialiser
@ -5189,6 +5190,7 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Impossib
STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Les véhicules ne peuvent attendre qu'aux stations STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Les véhicules ne peuvent attendre qu'aux stations
STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Ce véhicule ne s'arrête pas à cette station STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Ce véhicule ne s'arrête pas à cette station
STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... l'horaire est incomplet STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... l'horaire est incomplet
STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... cet horaire n'a pas encore démarré
# Sign related errors # Sign related errors
STR_ERROR_TOO_MANY_SIGNS :{WHITE}... trop de panneaux STR_ERROR_TOO_MANY_SIGNS :{WHITE}... trop de panneaux

View File

@ -501,7 +501,8 @@ NWidgetBase *MakeCargoesLegendLinkGraphGUI(int *biggest_index)
spc->SetResize(0, 0); spc->SetResize(0, 0);
col->Add(spc); col->Add(spc);
} }
panel->Add(col); /* If there are no cargo specs defined, then col won't have been created so don't add it. */
if (col != nullptr) panel->Add(col);
*biggest_index = WID_LGL_CARGO_LAST; *biggest_index = WID_LGL_CARGO_LAST;
return panel; return panel;
} }

View File

@ -58,7 +58,7 @@ static std::chrono::steady_clock::time_point _chatmessage_dirty_time;
* the left and pixels from the bottom. The height is the maximum height. * the left and pixels from the bottom. The height is the maximum height.
*/ */
static PointDimension _chatmsg_box; static PointDimension _chatmsg_box;
static uint8_t *_chatmessage_backup = nullptr; ///< Backup in case text is moved. static ReusableBuffer<uint8_t> _chatmessage_backup; ///< Backup in case text is moved.
/** /**
* Test if there are any chat messages to display. * Test if there are any chat messages to display.
@ -103,7 +103,6 @@ void NetworkReInitChatBoxSize()
{ {
_chatmsg_box.y = 3 * FONT_HEIGHT_NORMAL; _chatmsg_box.y = 3 * FONT_HEIGHT_NORMAL;
_chatmsg_box.height = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + ScaleGUITrad(NETWORK_CHAT_LINE_SPACING)) + ScaleGUITrad(4); _chatmsg_box.height = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + ScaleGUITrad(NETWORK_CHAT_LINE_SPACING)) + ScaleGUITrad(4);
_chatmessage_backup = ReallocT(_chatmessage_backup, static_cast<size_t>(_chatmsg_box.width) * _chatmsg_box.height * BlitterFactory::GetCurrentBlitter()->GetBytesPerPixel());
} }
/** Initialize all buffers of the chat visualisation. */ /** Initialize all buffers of the chat visualisation. */
@ -156,7 +155,7 @@ void NetworkUndrawChatMessage()
_chatmessage_visible = false; _chatmessage_visible = false;
/* Put our 'shot' back to the screen */ /* Put our 'shot' back to the screen */
blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height); blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup.GetBuffer(), width, height);
/* And make sure it is updated next time */ /* And make sure it is updated next time */
VideoDriver::GetInstance()->MakeDirty(x, y, width, height); VideoDriver::GetInstance()->MakeDirty(x, y, width, height);
@ -208,10 +207,9 @@ void NetworkDrawChatMessage()
} }
if (width <= 0 || height <= 0) return; if (width <= 0 || height <= 0) return;
assert(blitter->BufferSize(width, height) <= static_cast<size_t>(_chatmsg_box.width) * _chatmsg_box.height * blitter->GetBytesPerPixel());
/* Make a copy of the screen as it is before painting (for undraw) */ /* Make a copy of the screen as it is before painting (for undraw) */
blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height); uint8_t *buffer = _chatmessage_backup.Allocate(BlitterFactory::GetCurrentBlitter()->BufferSize(width, height));
blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), buffer, width, height);
_cur_dpi = &_screen; // switch to _screen painting _cur_dpi = &_screen; // switch to _screen painting