Merge branch 'master' into jgrpp

# Conflicts:
#	src/blitter/32bpp_anim.hpp
#	src/blitter/32bpp_base.hpp
#	src/blitter/8bpp_base.hpp
#	src/blitter/null.hpp
#	src/cheat_gui.cpp
#	src/gfx.cpp
#	src/linkgraph/linkgraph.cpp
#	src/spriteloader/grf.cpp
#	src/station_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2023-01-03 11:36:24 +00:00
27 changed files with 117 additions and 96 deletions

View File

@@ -621,9 +621,9 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int left, int top, int width,
Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y); Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y);
} }
int Blitter_32bppAnim::BufferSize(int width, int height) size_t Blitter_32bppAnim::BufferSize(uint width, uint height)
{ {
return width * height * (sizeof(uint32) + sizeof(uint16)); return (sizeof(uint32) + sizeof(uint16)) * width * height;
} }
void Blitter_32bppAnim::PaletteAnimate(const Palette &palette) void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)

View File

@@ -46,7 +46,7 @@ public:
void CopyFromBuffer(void *video, const void *src, int width, int height) override; void CopyFromBuffer(void *video, const void *src, int width, int height) override;
void CopyToBuffer(const void *video, void *dst, int width, int height) override; void CopyToBuffer(const void *video, void *dst, int width, int height) override;
void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override; void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override;
int BufferSize(int width, int 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;

View File

@@ -170,9 +170,9 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int left, int top, int width,
} }
} }
int Blitter_32bppBase::BufferSize(int width, int height) size_t Blitter_32bppBase::BufferSize(uint width, uint height)
{ {
return width * height * sizeof(uint32); return sizeof(uint32) * width * height;
} }
void Blitter_32bppBase::PaletteAnimate(const Palette &palette) void Blitter_32bppBase::PaletteAnimate(const Palette &palette)

View File

@@ -30,7 +30,7 @@ public:
void CopyToBuffer(const void *video, void *dst, int width, int height) override; void CopyToBuffer(const void *video, void *dst, int width, int height) override;
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override; void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override; void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override;
int BufferSize(int width, int 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; } int GetBytesPerPixel() override { return 4; }

View File

@@ -31,9 +31,10 @@ void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
if (_screen_disable_anim) { if (_screen_disable_anim) {
Blitter_32bppOptimized::SetPixel(video, x, y, colour); Blitter_32bppOptimized::SetPixel(video, x, y, colour);
} else { } else {
*((Colour *)video + x + y * _screen.pitch) = _black_colour; size_t y_offset = static_cast<size_t>(y) * _screen.pitch;
*((Colour *)video + x + y_offset) = _black_colour;
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * _screen.pitch] = colour; VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y_offset] = colour;
} }
} }
@@ -571,9 +572,9 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int left, int top, int width,
Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y); Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y);
} }
int Blitter_40bppAnim::BufferSize(int width, int height) size_t Blitter_40bppAnim::BufferSize(uint width, uint height)
{ {
return width * height * (sizeof(uint32) + sizeof(uint8)); return (sizeof(uint32) + sizeof(uint8)) * width * height;
} }
Blitter::PaletteAnimation Blitter_40bppAnim::UsePaletteAnimation() Blitter::PaletteAnimation Blitter_40bppAnim::UsePaletteAnimation()

View File

@@ -32,7 +32,7 @@ public:
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override; void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override; Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
int BufferSize(int width, int height) override; size_t BufferSize(uint width, uint height) override;
Blitter::PaletteAnimation UsePaletteAnimation() override; Blitter::PaletteAnimation UsePaletteAnimation() override;
bool NeedsAnimationBuffer() override; bool NeedsAnimationBuffer() override;

View File

@@ -159,9 +159,9 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int left, int top, int width, i
} }
} }
int Blitter_8bppBase::BufferSize(int width, int height) size_t Blitter_8bppBase::BufferSize(uint width, uint height)
{ {
return width * height; return static_cast<size_t>(width) * height;
} }
void Blitter_8bppBase::PaletteAnimate(const Palette &palette) void Blitter_8bppBase::PaletteAnimate(const Palette &palette)

View File

@@ -27,7 +27,7 @@ public:
void CopyToBuffer(const void *video, void *dst, int width, int height) override; void CopyToBuffer(const void *video, void *dst, int width, int height) override;
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override; void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override; void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override;
int BufferSize(int width, int 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; } int GetBytesPerPixel() override { return 1; }

View File

@@ -224,7 +224,7 @@ public:
* @param height The height of the buffer-to-be. * @param height The height of the buffer-to-be.
* @return The size needed for the buffer. * @return The size needed for the buffer.
*/ */
virtual int BufferSize(int width, int height) = 0; virtual size_t BufferSize(uint width, uint height) = 0;
/** /**
* Called when the 8bpp palette is changed; you should redraw all pixels on the screen that * Called when the 8bpp palette is changed; you should redraw all pixels on the screen that

View File

@@ -30,7 +30,7 @@ public:
void CopyToBuffer(const void *video, void *dst, int width, int height) override {}; void CopyToBuffer(const void *video, void *dst, int width, int height) override {};
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override {}; void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override {};
void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override {}; void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override {};
int BufferSize(int width, int height) override { return 0; }; size_t BufferSize(uint width, uint height) override { return 0; };
void PaletteAnimate(const Palette &palette) override { }; void PaletteAnimate(const Palette &palette) override { };
Blitter::PaletteAnimation UsePaletteAnimation() override { return Blitter::PALETTE_ANIMATION_NONE; }; Blitter::PaletteAnimation UsePaletteAnimation() override { return Blitter::PALETTE_ANIMATION_NONE; };

View File

@@ -390,7 +390,7 @@ bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
{ {
assert(info != nullptr && data != nullptr); assert(info != nullptr && data != nullptr);
data->bitmap = CallocT<byte>(info->width * info->height * ((info->bpp == 24) ? 3 : 1)); data->bitmap = CallocT<byte>(static_cast<size_t>(info->width) * info->height * ((info->bpp == 24) ? 3 : 1));
/* Load image */ /* Load image */
SetStreamOffset(buffer, info->offset); SetStreamOffset(buffer, info->offset);

View File

@@ -242,7 +242,7 @@ const Sprite *FreeTypeFontCache::InternalGetGlyph(GlyphID key, bool aa)
/* FreeType has rendered the glyph, now we allocate a sprite and copy the image into it */ /* FreeType has rendered the glyph, now we allocate a sprite and copy the image into it */
SpriteLoader::Sprite sprite; SpriteLoader::Sprite sprite;
sprite.AllocateData(ZOOM_LVL_NORMAL, width * height); sprite.AllocateData(ZOOM_LVL_NORMAL, static_cast<size_t>(width) * height);
sprite.type = ST_FONT; sprite.type = ST_FONT;
sprite.colours = (aa ? SCC_PAL | SCC_ALPHA : SCC_PAL); sprite.colours = (aa ? SCC_PAL | SCC_ALPHA : SCC_PAL);
sprite.width = width; sprite.width = width;

View File

@@ -1281,9 +1281,10 @@ std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo
const SpriteID real_sprite = GB(spriteId, 0, SPRITE_WIDTH); const SpriteID real_sprite = GB(spriteId, 0, SPRITE_WIDTH);
const Sprite *sprite = GetSprite(real_sprite, ST_NORMAL); const Sprite *sprite = GetSprite(real_sprite, ST_NORMAL);
Dimension dim = GetSpriteSize(real_sprite, nullptr, zoom); Dimension dim = GetSpriteSize(real_sprite, nullptr, zoom);
std::unique_ptr<uint32[]> result(new uint32[dim.width * dim.height]); size_t dim_size = static_cast<size_t>(dim.width) * dim.height;
std::unique_ptr<uint32[]> result(new uint32[dim_size]);
/* Set buffer to fully transparent. */ /* Set buffer to fully transparent. */
MemSetT(result.get(), 0, dim.width * dim.height); MemSetT(result.get(), 0, dim_size);
/* Prepare new DrawPixelInfo - Normally this would be the screen but we want to draw to another buffer here. /* Prepare new DrawPixelInfo - Normally this would be the screen but we want to draw to another buffer here.
* Normally, pitch would be scaled screen width, but in our case our "screen" is only the sprite width wide. */ * Normally, pitch would be scaled screen width, but in our case our "screen" is only the sprite width wide. */
@@ -1296,11 +1297,13 @@ std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo
dpi.height = dim.height; dpi.height = dim.height;
dpi.zoom = zoom; dpi.zoom = zoom;
dim_size = static_cast<size_t>(dim.width) * dim.height;
/* If the current blitter is a paletted blitter, we have to render to an extra buffer and resolve the palette later. */ /* If the current blitter is a paletted blitter, we have to render to an extra buffer and resolve the palette later. */
std::unique_ptr<byte[]> pal_buffer{}; std::unique_ptr<byte[]> pal_buffer{};
if (blitter->GetScreenDepth() == 8) { if (blitter->GetScreenDepth() == 8) {
pal_buffer.reset(new byte[dim.width * dim.height]); pal_buffer.reset(new byte[dim_size]);
MemSetT(pal_buffer.get(), 0, dim.width * dim.height); MemSetT(pal_buffer.get(), 0, dim_size);
dpi.dst_ptr = pal_buffer.get(); dpi.dst_ptr = pal_buffer.get();
} }
@@ -1315,7 +1318,7 @@ std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo
/* Resolve palette. */ /* Resolve palette. */
uint32 *dst = result.get(); uint32 *dst = result.get();
const byte *src = pal_buffer.get(); const byte *src = pal_buffer.get();
for (size_t i = 0; i < dim.height * dim.width; ++i) { for (size_t i = 0; i < dim_size; ++i) {
*dst++ = _cur_palette.palette[*src++].data; *dst++ = _cur_palette.palette[*src++].data;
} }
} }

View File

@@ -185,7 +185,7 @@ GroundVehicleAcceleration GroundVehicle<T, Type>::GetAcceleration()
} }
/* Air drag; the air drag coefficient is in an arbitrary NewGRF-unit, /* Air drag; the air drag coefficient is in an arbitrary NewGRF-unit,
* so we need some magic conversion factor. */ * so we need some magic conversion factor. */
resistance += (area * this->gcache.cached_air_drag * speed * speed) / 1000; resistance += static_cast<int64>(area) * this->gcache.cached_air_drag * speed * speed / 1000;
resistance += this->GetSlopeResistance(); resistance += this->GetSlopeResistance();

View File

@@ -188,7 +188,7 @@ static bool ReadHeightmapPNG(const char *filename, uint *x, uint *y, byte **map)
} }
if (map != nullptr) { if (map != nullptr) {
*map = MallocT<byte>(width * height); *map = MallocT<byte>(static_cast<size_t>(width) * height);
ReadHeightmapPNGImageData(*map, png_ptr, info_ptr); ReadHeightmapPNGImageData(*map, png_ptr, info_ptr);
} }
@@ -303,7 +303,7 @@ static bool ReadHeightmapBMP(const char *filename, uint *x, uint *y, byte **map)
return false; return false;
} }
*map = MallocT<byte>(info.width * info.height); *map = MallocT<byte>(static_cast<size_t>(info.width) * info.height);
ReadHeightmapBMPImageData(*map, &info, &data); ReadHeightmapBMPImageData(*map, &info, &data);
} }

View File

@@ -2865,6 +2865,8 @@ STR_FOUND_TOWN_RANDOM_TOWN_BUTTON :{BLACK}Willekeu
STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP :{BLACK}Hiermee sticht je een stad op een willekeurige locatie STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP :{BLACK}Hiermee sticht je een stad op een willekeurige locatie
STR_FOUND_TOWN_MANY_RANDOM_TOWNS :{BLACK}Veel willekeurige steden STR_FOUND_TOWN_MANY_RANDOM_TOWNS :{BLACK}Veel willekeurige steden
STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP :{BLACK}Verspreid willekeurig geplaatste steden over de kaart STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP :{BLACK}Verspreid willekeurig geplaatste steden over de kaart
STR_FOUND_TOWN_EXPAND_ALL_TOWNS :{BLACK}Alle steden uitbreiden
STR_FOUND_TOWN_EXPAND_ALL_TOWNS_TOOLTIP :{BLACK}Laat alle steden een klein beetje groeien
STR_FOUND_TOWN_NAME_TITLE :{YELLOW}Plaatsnaam: STR_FOUND_TOWN_NAME_TITLE :{YELLOW}Plaatsnaam:
STR_FOUND_TOWN_NAME_EDITOR_TITLE :{BLACK}Plaatsnaam invoeren STR_FOUND_TOWN_NAME_EDITOR_TITLE :{BLACK}Plaatsnaam invoeren
@@ -4530,22 +4532,22 @@ STR_TIMETABLE_STARTING_DATE :{BLACK}Startdat
STR_TIMETABLE_STARTING_DATE_TOOLTIP :{BLACK}Selecteer een datum als startpunt voor deze dienstregeling. Ctrl+klik verdeelt alle voertuigen die deze orders delen gelijkmatig vanaf deze datum op basis van hun relatieve volgorde, als de order volledig is ingeroosterd STR_TIMETABLE_STARTING_DATE_TOOLTIP :{BLACK}Selecteer een datum als startpunt voor deze dienstregeling. Ctrl+klik verdeelt alle voertuigen die deze orders delen gelijkmatig vanaf deze datum op basis van hun relatieve volgorde, als de order volledig is ingeroosterd
STR_TIMETABLE_CHANGE_TIME :{BLACK}Tijd wijzigen STR_TIMETABLE_CHANGE_TIME :{BLACK}Tijd wijzigen
STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Verander de tijdsduur die de geselecteerde order mag duren STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Verander de tijdsduur die de geselecteerde order mag duren. Met Ctrl+klik stel je de tijd voor alle orders in
STR_TIMETABLE_CLEAR_TIME :{BLACK}Tijd wissen STR_TIMETABLE_CLEAR_TIME :{BLACK}Tijd wissen
STR_TIMETABLE_CLEAR_TIME_TOOLTIP :{BLACK}Verwijder de tijdsduur die de geselecteerde order mag duren STR_TIMETABLE_CLEAR_TIME_TOOLTIP :{BLACK}Verwijder de tijdsduur die de geselecteerde order mag duren. Met Ctrl+klik wis je de tijd voor alle orders
STR_TIMETABLE_CHANGE_SPEED :{BLACK}Maximumsnelheid wijzigen STR_TIMETABLE_CHANGE_SPEED :{BLACK}Maximumsnelheid wijzigen
STR_TIMETABLE_CHANGE_SPEED_TOOLTIP :{BLACK}Wijzig de maximumsnelheid voor de gekozen order STR_TIMETABLE_CHANGE_SPEED_TOOLTIP :{BLACK}Wijzig de maximumsnelheid voor de gekozen order. Met Ctrl+klik stel je de snelheid voor alle orders in
STR_TIMETABLE_CLEAR_SPEED :{BLACK}Snelheidslimiet wissen STR_TIMETABLE_CLEAR_SPEED :{BLACK}Snelheidslimiet wissen
STR_TIMETABLE_CLEAR_SPEED_TOOLTIP :{BLACK}Verwijder de maximumsnelheid van de gekozen order STR_TIMETABLE_CLEAR_SPEED_TOOLTIP :{BLACK}Verwijder de maximumsnelheid van de gekozen order. Met Ctrl+klik wis je de snelheid voor alle orders
STR_TIMETABLE_RESET_LATENESS :{BLACK}Vertragingsteller terugstellen STR_TIMETABLE_RESET_LATENESS :{BLACK}Vertragingsteller terugstellen
STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Stel de vertragingsteller terug zodat het voertuig op tijd is STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Stel de vertragingsteller terug zodat het voertuig op tijd is
STR_TIMETABLE_AUTOFILL :{BLACK}Automatisch vullen STR_TIMETABLE_AUTOFILL :{BLACK}Automatisch vullen
STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Vul de dienstregeling automatisch in aan de hand van de volgende reis (Ctrl+klik om te proberen om wachttijden te bewaren) STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Vul de dienstregeling automatisch in aan de hand van de volgende reis. Ctrl+klik om te proberen om wachttijden te bewaren
STR_TIMETABLE_EXPECTED :{BLACK}Verwacht STR_TIMETABLE_EXPECTED :{BLACK}Verwacht
STR_TIMETABLE_SCHEDULED :{BLACK}Volgens dienstregeling STR_TIMETABLE_SCHEDULED :{BLACK}Volgens dienstregeling
@@ -4801,6 +4803,7 @@ STR_ERROR_TOO_MANY_INDUSTRIES :{WHITE}... te v
STR_ERROR_CAN_T_GENERATE_INDUSTRIES :{WHITE}Kan geen industrieën genereren... STR_ERROR_CAN_T_GENERATE_INDUSTRIES :{WHITE}Kan geen industrieën genereren...
STR_ERROR_CAN_T_BUILD_HERE :{WHITE}Kan {STRING} hier niet bouwen... STR_ERROR_CAN_T_BUILD_HERE :{WHITE}Kan {STRING} hier niet bouwen...
STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY :{WHITE}Kan dit type industrie hier niet bouwen... STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY :{WHITE}Kan dit type industrie hier niet bouwen...
STR_ERROR_CAN_T_PROSPECT_INDUSTRY :{WHITE}Kan industrie niet onderzoeken...
STR_ERROR_INDUSTRY_TOO_CLOSE :{WHITE}... te dicht bij een andere industrie STR_ERROR_INDUSTRY_TOO_CLOSE :{WHITE}... te dicht bij een andere industrie
STR_ERROR_MUST_FOUND_TOWN_FIRST :{WHITE}... moet eerst dorp bouwen STR_ERROR_MUST_FOUND_TOWN_FIRST :{WHITE}... moet eerst dorp bouwen
STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN :{WHITE}... slechts één per stad toegestaan STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN :{WHITE}... slechts één per stad toegestaan
@@ -4815,6 +4818,8 @@ STR_ERROR_FOREST_CAN_ONLY_BE_PLANTED :{WHITE}... boss
STR_ERROR_CAN_ONLY_BE_BUILT_ABOVE_SNOW_LINE :{WHITE}... kan alleen boven de sneeuwlijn gebouwd worden STR_ERROR_CAN_ONLY_BE_BUILT_ABOVE_SNOW_LINE :{WHITE}... kan alleen boven de sneeuwlijn gebouwd worden
STR_ERROR_CAN_ONLY_BE_BUILT_BELOW_SNOW_LINE :{WHITE}... kan alleen onder de sneeuwlijn gebouwd worden STR_ERROR_CAN_ONLY_BE_BUILT_BELOW_SNOW_LINE :{WHITE}... kan alleen onder de sneeuwlijn gebouwd worden
STR_ERROR_PROSPECTING_WAS_UNLUCKY :{WHITE}De financiering is mislukt vanwege domme pech. Probeer het opnieuw.
STR_ERROR_NO_SUITABLE_PLACES_FOR_PROSPECTING :{WHITE}Er was geen geschikte plek voor onderzoek voor deze industrie
STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES :{WHITE}Er waren geen geschikte locaties voor {STRING}-industrieën STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES :{WHITE}Er waren geen geschikte locaties voor {STRING}-industrieën
STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES_EXPLANATION :{WHITE}Wijzig de instellingen van wereldontwikkeling om een betere kaart te krijgen STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES_EXPLANATION :{WHITE}Wijzig de instellingen van wereldontwikkeling om een betere kaart te krijgen

View File

@@ -2304,7 +2304,7 @@ STR_CONFIG_SETTING_TOWN_GROWTH_FAST :duża
STR_CONFIG_SETTING_TOWN_GROWTH_VERY_FAST :bardzo duża STR_CONFIG_SETTING_TOWN_GROWTH_VERY_FAST :bardzo duża
STR_CONFIG_SETTING_LARGER_TOWNS :Proporcje miast, które będą metropoliami: {STRING} STR_CONFIG_SETTING_LARGER_TOWNS :Proporcje miast, które będą metropoliami: {STRING}
STR_CONFIG_SETTING_LARGER_TOWNS_HELPTEXT :Liczba miast, które staną się metropoliami - czyli miastami, które na początku są większe i szybciej się rozwijają STR_CONFIG_SETTING_LARGER_TOWNS_HELPTEXT :Liczba miast, które staną się metropoliami - czyli miastami, które od początku są większe i szybciej się rozwijają
STR_CONFIG_SETTING_LARGER_TOWNS_VALUE :1 z {COMMA} STR_CONFIG_SETTING_LARGER_TOWNS_VALUE :1 z {COMMA}
###setting-zero-is-special ###setting-zero-is-special
STR_CONFIG_SETTING_LARGER_TOWNS_DISABLED :Żadne STR_CONFIG_SETTING_LARGER_TOWNS_DISABLED :Żadne
@@ -3245,6 +3245,8 @@ STR_FOUND_TOWN_RANDOM_TOWN_BUTTON :{BLACK}Losowe m
STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP :{BLACK}Budowa miasta w losowym miejscu STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP :{BLACK}Budowa miasta w losowym miejscu
STR_FOUND_TOWN_MANY_RANDOM_TOWNS :{BLACK}Wiele losowych miast STR_FOUND_TOWN_MANY_RANDOM_TOWNS :{BLACK}Wiele losowych miast
STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP :{BLACK}Pokryj mapę losowo położonymi miastami STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP :{BLACK}Pokryj mapę losowo położonymi miastami
STR_FOUND_TOWN_EXPAND_ALL_TOWNS :{BLACK}Rozszerz wszystkie miasta
STR_FOUND_TOWN_EXPAND_ALL_TOWNS_TOOLTIP :{BLACK}Zwiększ trochę rozmiar wszystkich miast
STR_FOUND_TOWN_NAME_TITLE :{YELLOW}Nazwa miasta: STR_FOUND_TOWN_NAME_TITLE :{YELLOW}Nazwa miasta:
STR_FOUND_TOWN_NAME_EDITOR_TITLE :{BLACK}Wprowadź nazwę miasta STR_FOUND_TOWN_NAME_EDITOR_TITLE :{BLACK}Wprowadź nazwę miasta
@@ -3714,27 +3716,30 @@ STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE :Typ szyn
STR_NEWGRF_INSPECT_QUERY_CAPTION :{WHITE}NewGFR zmienna 60+parametr x (heksadecymalnie) STR_NEWGRF_INSPECT_QUERY_CAPTION :{WHITE}NewGFR zmienna 60+parametr x (heksadecymalnie)
# Sprite aligner window # Sprite aligner window
STR_SPRITE_ALIGNER_CAPTION :{WHITE}Dostosowanie obrazka {COMMA} ({STRING}) STR_SPRITE_ALIGNER_CAPTION :{WHITE}Wyrównywanie sprite'a {COMMA} ({STRING})
STR_SPRITE_ALIGNER_NEXT_BUTTON :{BLACK}Następny obrazek STR_SPRITE_ALIGNER_NEXT_BUTTON :{BLACK}Następny sprite
STR_SPRITE_ALIGNER_NEXT_TOOLTIP :{BLACK}Idź do następnego normalnego obrazka, pomijając jakiekolwiek pseudo/kolorowe/znakowe obrazki i zawijaj je od ostatniego do pierwszego STR_SPRITE_ALIGNER_NEXT_TOOLTIP :{BLACK}Idź do następnego normalnego sprite'a, pomijając jakiekolwiek pseudo/przekolorowane/czcionkowe sprite'y i ewentualnie przewiń od ostatniego do pierwszego
STR_SPRITE_ALIGNER_GOTO_BUTTON :{BLACK}Idź do obrazka STR_SPRITE_ALIGNER_GOTO_BUTTON :{BLACK}Idź do sprite'a
STR_SPRITE_ALIGNER_GOTO_TOOLTIP :{BLACK}Idź do danego obrazka. Jeśli dany obrazek nie jest normalnym obrazkiem, idź do następnego normalnego obrazka STR_SPRITE_ALIGNER_GOTO_TOOLTIP :{BLACK}Idź do danego sprite'a. Jeśli dany sprite nie jest normalnym spritem, przejdź do następnego normalnego sprite'a
STR_SPRITE_ALIGNER_PREVIOUS_BUTTON :{BLACK}Poprzedni obrazek STR_SPRITE_ALIGNER_PREVIOUS_BUTTON :{BLACK}Poprzedni sprite
STR_SPRITE_ALIGNER_PREVIOUS_TOOLTIP :{BLACK}Idź do poprzedniego normalnego obrazka, pomijając jakiekolwiek pseudo/kolorowe/znakowe obrazki i zawijaj je od pierwszego do ostatniego STR_SPRITE_ALIGNER_PREVIOUS_TOOLTIP :{BLACK}Idź do poprzedniego normalnego sprite'a, pomijając jakiekolwiek pseudo/przekolorowane/czcionkowe sprite'y i ewentualnie przewiń od pierwszego do ostatniego
STR_SPRITE_ALIGNER_SPRITE_TOOLTIP :{BLACK}Przedstawienie wybranego orbazka. Dostosowanie jest ignorowane podczas rysowania tego obrazka STR_SPRITE_ALIGNER_SPRITE_TOOLTIP :{BLACK}Prezentacja wybranego sprite'a. Wyrównanie jest ignorowane podczas rysowania tego sprite'a
STR_SPRITE_ALIGNER_MOVE_TOOLTIP :{BLACK}Poruszaj obrazkiem, zmieniając przesunięcia X i Y. Ctrl+klik aby przesunąć o 8 jednostek na raz. STR_SPRITE_ALIGNER_MOVE_TOOLTIP :{BLACK}Poruszaj spritem, zmieniając przesunięcia X i Y. Ctrl+klik aby przesunąć o 8 jednostek na raz
###length 2 ###length 2
STR_SPRITE_ALIGNER_CENTRE_OFFSET :{BLACK}Wyśrodkowanie przesunięcia
STR_SPRITE_ALIGNER_CENTRE_SPRITE :{BLACK}Wyśrodkowanie sprite'a
STR_SPRITE_ALIGNER_CROSSHAIR :{BLACK}Prowadnice
STR_SPRITE_ALIGNER_RESET_BUTTON :{BLACK}Resetuj zależność STR_SPRITE_ALIGNER_RESET_BUTTON :{BLACK}Wyzeruj względność
STR_SPRITE_ALIGNER_RESET_TOOLTIP :{BLACK}Resetuj aktualne offsety zależne STR_SPRITE_ALIGNER_RESET_TOOLTIP :{BLACK}Wyzeruj aktualne względne przesunięcia
STR_SPRITE_ALIGNER_OFFSETS_ABS :{BLACK}X offset: {NUM}, Y offset: {NUM} (Całkowity) STR_SPRITE_ALIGNER_OFFSETS_ABS :{BLACK}Przesunięcie X: {NUM}, przesunięcie Y: {NUM} (bezwzględne)
STR_SPRITE_ALIGNER_OFFSETS_REL :{BLACK}X offset: {NUM}, Y offset: {NUM} (Zależny) STR_SPRITE_ALIGNER_OFFSETS_REL :{BLACK}Przesunięcie X: {NUM}, przesunięcie Y: {NUM} (względne)
STR_SPRITE_ALIGNER_PICKER_BUTTON :{BLACK}Wybierz obrazek STR_SPRITE_ALIGNER_PICKER_BUTTON :{BLACK}Wybierz sprite'a
STR_SPRITE_ALIGNER_PICKER_TOOLTIP :{BLACK}Wybierz obrazek z dowolnego miejsca na ekranie STR_SPRITE_ALIGNER_PICKER_TOOLTIP :{BLACK}Wybierz sprite'a z dowolnego miejsca na ekranie
STR_SPRITE_ALIGNER_GOTO_CAPTION :{WHITE}Idź do obrazka STR_SPRITE_ALIGNER_GOTO_CAPTION :{WHITE}Idź do sprite'a
# NewGRF (self) generated warnings/errors # NewGRF (self) generated warnings/errors
STR_NEWGRF_ERROR_MSG_INFO :{SILVER}{STRING} STR_NEWGRF_ERROR_MSG_INFO :{SILVER}{STRING}
@@ -4796,14 +4801,14 @@ STR_ORDERS_DELETE_BUTTON :{BLACK}Usuń
STR_ORDERS_DELETE_TOOLTIP :{BLACK}Usuń podświetlone polecenie STR_ORDERS_DELETE_TOOLTIP :{BLACK}Usuń podświetlone polecenie
STR_ORDERS_DELETE_ALL_TOOLTIP :{BLACK}Usuń wszystkie polecenia STR_ORDERS_DELETE_ALL_TOOLTIP :{BLACK}Usuń wszystkie polecenia
STR_ORDERS_STOP_SHARING_BUTTON :{BLACK}Przestań dzielić STR_ORDERS_STOP_SHARING_BUTTON :{BLACK}Przestań dzielić
STR_ORDERS_STOP_SHARING_TOOLTIP :{BLACK}Przestań dzielić listę poleceń. Ctrl+Klik dodatkowo usuwa wszystkie polecenia tego pojazdu STR_ORDERS_STOP_SHARING_TOOLTIP :{BLACK}Przestań współdzielić listę poleceń. Ctrl+klik dodatkowo usuwa wszystkie polecenia tego pojazdu
STR_ORDERS_GO_TO_BUTTON :{BLACK}Idź do STR_ORDERS_GO_TO_BUTTON :{BLACK}Idź do
STR_ORDER_GO_TO_NEAREST_DEPOT :Idź do najbliższego serwisu STR_ORDER_GO_TO_NEAREST_DEPOT :Idź do najbliższego serwisu
STR_ORDER_GO_TO_NEAREST_HANGAR :Leć do najbliższego hangaru STR_ORDER_GO_TO_NEAREST_HANGAR :Leć do najbliższego hangaru
STR_ORDER_CONDITIONAL :Warunkowy skok poleceń STR_ORDER_CONDITIONAL :Warunkowy skok poleceń
STR_ORDER_SHARE :Współdzielenie poleceń STR_ORDER_SHARE :Współdzielenie poleceń
STR_ORDERS_GO_TO_TOOLTIP :{BLACK}Wstaw nowe polecenie na końcu listy lub przed zaznaczonym poleceniem. Ctrl ustawi polecenie stacji na 'pełny załadunek dowolnego towaru', pkt. orientacyjnego na 'bez zatrzymywania się', a zajezdni na 'serwisuj'. Kliknięcie innego pojazdu kopiuje jego polecenia, ctrl+klik (lub 'Współdzielenie poleceń') pozwala na dzielenie z nim poleceń. Polecenie zajezdni wyłącza automatyczne serwisowanie pojazdu STR_ORDERS_GO_TO_TOOLTIP :{BLACK}Dodaj nowe polecenie na końcu listy lub przed zaznaczonym poleceniem. Ctrl ustawi polecenie stacji na pełny załadunek któregoś z towarów”, posterunku na bez zatrzymywania się, a zajezdni na serwisuj. Kliknięcie innego pojazdu kopiuje jego polecenia. „Współdzielenie poleceń” lub Ctrl+klik pozwala na współdzielenie z nim poleceń. Polecenie zajezdni wyłącza automatyczne serwisowanie tego pojazdu
STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP :{BLACK}Pokaż wszystkie pojazdy współdzielące te polecenia STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP :{BLACK}Pokaż wszystkie pojazdy współdzielące te polecenia
@@ -4913,22 +4918,22 @@ STR_TIMETABLE_STARTING_DATE :{BLACK}Data poc
STR_TIMETABLE_STARTING_DATE_TOOLTIP :{BLACK}Wybierz początkową datę rozkładu jazdy. Ctrl+klik rozłoży równomierne wszystkie pojazdy współdzielące ten rozkład, począwszy od podanej daty, zgodnie z ich kolejnością, o ile rozkład ten jest kompletny STR_TIMETABLE_STARTING_DATE_TOOLTIP :{BLACK}Wybierz początkową datę rozkładu jazdy. Ctrl+klik rozłoży równomierne wszystkie pojazdy współdzielące ten rozkład, począwszy od podanej daty, zgodnie z ich kolejnością, o ile rozkład ten jest kompletny
STR_TIMETABLE_CHANGE_TIME :{BLACK}Zmień czas STR_TIMETABLE_CHANGE_TIME :{BLACK}Zmień czas
STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Zmień ilość czasu którą zaznaczone zadanie powinno zająć STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Zmień ilość czasu, jaką powinno zająć zaznaczone polecenie. Ctrl+klik ustala czas dla wszystkich poleceń
STR_TIMETABLE_CLEAR_TIME :{BLACK}Usuń czas STR_TIMETABLE_CLEAR_TIME :{BLACK}Usuń czas
STR_TIMETABLE_CLEAR_TIME_TOOLTIP :{BLACK}Usuń ilość czasu przeznaczoną na zaznaczone zadanie STR_TIMETABLE_CLEAR_TIME_TOOLTIP :{BLACK}Wyczyść ilość czasu w zaznaczonym poleceniu. Ctrl+klik wyczyści czas we wszystkich poleceniach
STR_TIMETABLE_CHANGE_SPEED :{BLACK}Zmień limit prędkości STR_TIMETABLE_CHANGE_SPEED :{BLACK}Zmień limit prędkości
STR_TIMETABLE_CHANGE_SPEED_TOOLTIP :{BLACK}Zmień maksymalną prędkość podróży w zaznaczonym poleceniu STR_TIMETABLE_CHANGE_SPEED_TOOLTIP :{BLACK}Zmień maksymalną prędkość przejazdu w zaznaczonym poleceniu. Ctrl+klik zmieni prędkość we wszystkich poleceniach
STR_TIMETABLE_CLEAR_SPEED :{BLACK}Wyczyść limit prędkości STR_TIMETABLE_CLEAR_SPEED :{BLACK}Wyczyść limit prędkości
STR_TIMETABLE_CLEAR_SPEED_TOOLTIP :{BLACK}Wyczyść maksymalną prędkość podróży w zaznaczonym poleceniu STR_TIMETABLE_CLEAR_SPEED_TOOLTIP :{BLACK}Wyczyść maksymalną prędkość przejazdu w zaznaczonym poleceniu. Ctrl+klik wyczyści prędkość we wszystkich poleceniach
STR_TIMETABLE_RESET_LATENESS :{BLACK}Wyzeruj spóźnienia STR_TIMETABLE_RESET_LATENESS :{BLACK}Wyzeruj spóźnienia
STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Wyzeruj licznik spóźnienia, aby pojazd podróżował zgodnie z rozkładem jazdy STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Wyzeruj licznik spóźnienia, aby pojazd podróżował zgodnie z rozkładem jazdy
STR_TIMETABLE_AUTOFILL :{BLACK}Automat. wypełnienie STR_TIMETABLE_AUTOFILL :{BLACK}Automat. wypełnienie
STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Wypełnij automatycznie rozkład jazdy wartościami z następnego przejazdu (Ctrl+klik, aby spróbować utrzymać czasy oczekiwania) STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Wypełnij automatycznie rozkład jazdy wartościami z następnego przejazdu. Ctrl+klik, aby spróbować utrzymać czasy oczekiwania
STR_TIMETABLE_EXPECTED :{BLACK}Wymagany STR_TIMETABLE_EXPECTED :{BLACK}Wymagany
STR_TIMETABLE_SCHEDULED :{BLACK}Zaplanowany STR_TIMETABLE_SCHEDULED :{BLACK}Zaplanowany
@@ -5184,6 +5189,7 @@ STR_ERROR_TOO_MANY_INDUSTRIES :{WHITE}... zbyt
STR_ERROR_CAN_T_GENERATE_INDUSTRIES :{WHITE}Nie można stworzyć przedsiębiorstw... STR_ERROR_CAN_T_GENERATE_INDUSTRIES :{WHITE}Nie można stworzyć przedsiębiorstw...
STR_ERROR_CAN_T_BUILD_HERE :{WHITE}Nie można tutaj wybudować: {STRING}... STR_ERROR_CAN_T_BUILD_HERE :{WHITE}Nie można tutaj wybudować: {STRING}...
STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY :{WHITE}Nie można tutaj wybudować tego przedsiębiorstwa... STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY :{WHITE}Nie można tutaj wybudować tego przedsiębiorstwa...
STR_ERROR_CAN_T_PROSPECT_INDUSTRY :{WHITE}Nie można znaleźć przedsiębiorstwa...
STR_ERROR_INDUSTRY_TOO_CLOSE :{WHITE}... zbyt blisko innego przedsiębiorstwa STR_ERROR_INDUSTRY_TOO_CLOSE :{WHITE}... zbyt blisko innego przedsiębiorstwa
STR_ERROR_MUST_FOUND_TOWN_FIRST :{WHITE}... należy najpierw wybudować miasto STR_ERROR_MUST_FOUND_TOWN_FIRST :{WHITE}... należy najpierw wybudować miasto
STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN :{WHITE}... dozwolone jedno na miasto STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN :{WHITE}... dozwolone jedno na miasto
@@ -5198,7 +5204,9 @@ STR_ERROR_FOREST_CAN_ONLY_BE_PLANTED :{WHITE}... las
STR_ERROR_CAN_ONLY_BE_BUILT_ABOVE_SNOW_LINE :{WHITE}... można zbudować tylko powyżej linii śniegu STR_ERROR_CAN_ONLY_BE_BUILT_ABOVE_SNOW_LINE :{WHITE}... można zbudować tylko powyżej linii śniegu
STR_ERROR_CAN_ONLY_BE_BUILT_BELOW_SNOW_LINE :{WHITE}... można zbudować tylko poniżej linii śniegu STR_ERROR_CAN_ONLY_BE_BUILT_BELOW_SNOW_LINE :{WHITE}... można zbudować tylko poniżej linii śniegu
STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES :{WHITE}Nie ma odpowiednich miejsc dla przedsiębiorstw '{STRING}' STR_ERROR_PROSPECTING_WAS_UNLUCKY :{WHITE}Ufundowanie pechowo nie powiodło się; spróbuj ponownie
STR_ERROR_NO_SUITABLE_PLACES_FOR_PROSPECTING :{WHITE}Nie ma odpowiednich miejsc do poszukiwań takiego przedsiębiorstwa
STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES :{WHITE}Nie ma odpowiednich miejsc dla przedsiębiorstw „{STRING}”
STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES_EXPLANATION :{WHITE}Zmień parametry tworzenia map, żeby uzyskać lepsze mapy STR_ERROR_NO_SUITABLE_PLACES_FOR_INDUSTRIES_EXPLANATION :{WHITE}Zmień parametry tworzenia map, żeby uzyskać lepsze mapy
# Station construction related errors # Station construction related errors

View File

@@ -171,7 +171,7 @@ static void AddEdge(LinkGraph::BaseEdge &edge, uint capacity, uint usage, uint32
{ {
edge.capacity = capacity; edge.capacity = capacity;
edge.usage = usage; edge.usage = usage;
edge.travel_time_sum = travel_time * capacity; edge.travel_time_sum = static_cast<uint64>(travel_time) * capacity;
if (mode & EUM_UNRESTRICTED) edge.last_unrestricted_update = _date; if (mode & EUM_UNRESTRICTED) edge.last_unrestricted_update = _date;
if (mode & EUM_RESTRICTED) edge.last_restricted_update = _date; if (mode & EUM_RESTRICTED) edge.last_restricted_update = _date;
if (mode & EUM_AIRCRAFT) edge.last_aircraft_update = _date; if (mode & EUM_AIRCRAFT) edge.last_aircraft_update = _date;
@@ -227,11 +227,11 @@ void LinkGraph::Edge::Update(uint capacity, uint usage, uint32 travel_time, Edge
if (mode & EUM_INCREASE) { if (mode & EUM_INCREASE) {
if (edge.travel_time_sum == 0) { if (edge.travel_time_sum == 0) {
edge.travel_time_sum = (edge.capacity + capacity) * travel_time; edge.travel_time_sum = static_cast<uint64>(edge.capacity + capacity) * travel_time;
} else if (travel_time == 0) { } else if (travel_time == 0) {
edge.travel_time_sum += (edge.travel_time_sum / edge.capacity) * capacity; edge.travel_time_sum += (edge.travel_time_sum / edge.capacity) * capacity;
} else { } else {
edge.travel_time_sum += travel_time * capacity; edge.travel_time_sum += static_cast<uint64>(travel_time) * capacity;
} }
edge.capacity += capacity; edge.capacity += capacity;
edge.usage += usage; edge.usage += usage;
@@ -240,13 +240,13 @@ void LinkGraph::Edge::Update(uint capacity, uint usage, uint32 travel_time, Edge
* the capacity increase. */ * the capacity increase. */
if (capacity > edge.capacity) { if (capacity > edge.capacity) {
if (travel_time == 0) { if (travel_time == 0) {
edge.travel_time_sum = (edge.travel_time_sum / edge.capacity) * capacity; edge.travel_time_sum = static_cast<uint64>(edge.travel_time_sum / edge.capacity) * capacity;
} else { } else {
edge.travel_time_sum += (capacity - edge.capacity) * travel_time; edge.travel_time_sum += static_cast<uint64>(capacity - edge.capacity) * travel_time;
} }
edge.capacity = capacity; edge.capacity = capacity;
} else if (edge.travel_time_sum == 0) { } else if (edge.travel_time_sum == 0) {
edge.travel_time_sum = travel_time * edge.capacity; edge.travel_time_sum = static_cast<uint64>(travel_time) * edge.capacity;
} }
edge.usage = std::max(edge.usage, usage); edge.usage = std::max(edge.usage, usage);
} }

View File

@@ -108,7 +108,7 @@ 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, _chatmsg_box.width * _chatmsg_box.height * BlitterFactory::GetCurrentBlitter()->GetBytesPerPixel()); _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. */
@@ -214,7 +214,7 @@ void NetworkDrawChatMessage()
} }
if (width <= 0 || height <= 0) return; if (width <= 0 || height <= 0) return;
assert(blitter->BufferSize(width, height) <= (int)(_chatmsg_box.width * _chatmsg_box.height * blitter->GetBytesPerPixel())); 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); blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height);

View File

@@ -149,7 +149,7 @@ static bool MakeBMPImage(const char *name, ScreenshotCallback *callb, void *user
/* Setup the file header */ /* Setup the file header */
BitmapFileHeader bfh; BitmapFileHeader bfh;
bfh.type = TO_LE16('MB'); bfh.type = TO_LE16('MB');
bfh.size = TO_LE32(sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader) + pal_size + bytewidth * h); bfh.size = TO_LE32(sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader) + pal_size + static_cast<size_t>(bytewidth) * h);
bfh.reserved = 0; bfh.reserved = 0;
bfh.off_bits = TO_LE32(sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader) + pal_size); bfh.off_bits = TO_LE32(sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader) + pal_size);
@@ -392,7 +392,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
maxlines = Clamp(65536 / w, 16, 128); maxlines = Clamp(65536 / w, 16, 128);
/* now generate the bitmap bits */ /* now generate the bitmap bits */
void *buff = CallocT<uint8>(w * maxlines * bpp); // by default generate 128 lines at a time. void *buff = CallocT<uint8>(static_cast<size_t>(w) * maxlines * bpp); // by default generate 128 lines at a time.
y = 0; y = 0;
do { do {
@@ -499,7 +499,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
maxlines = Clamp(65536 / w, 16, 128); maxlines = Clamp(65536 / w, 16, 128);
/* now generate the bitmap bits */ /* now generate the bitmap bits */
uint8 *buff = CallocT<uint8>(w * maxlines); // by default generate 128 lines at a time. uint8 *buff = CallocT<uint8>(static_cast<size_t>(w) * maxlines); // by default generate 128 lines at a time.
y = 0; y = 0;
do { do {

View File

@@ -284,7 +284,7 @@ static bool ResizeSpriteIn(SpriteLoader::Sprite *sprite, ZoomLevel src, ZoomLeve
sprite[tgt].y_offs = sprite[src].y_offs * scaled_1; sprite[tgt].y_offs = sprite[src].y_offs * scaled_1;
sprite[tgt].colours = sprite[src].colours; sprite[tgt].colours = sprite[src].colours;
sprite[tgt].AllocateData(tgt, sprite[tgt].width * sprite[tgt].height); sprite[tgt].AllocateData(tgt, static_cast<size_t>(sprite[tgt].width) * sprite[tgt].height);
SpriteLoader::CommonPixel *dst = sprite[tgt].data; SpriteLoader::CommonPixel *dst = sprite[tgt].data;
for (int y = 0; y < sprite[tgt].height; y++) { for (int y = 0; y < sprite[tgt].height; y++) {
@@ -307,7 +307,7 @@ static void ResizeSpriteOut(SpriteLoader::Sprite *sprite, ZoomLevel zoom)
sprite[zoom].y_offs = UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].y_offs, zoom); sprite[zoom].y_offs = UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].y_offs, zoom);
sprite[zoom].colours = sprite[ZOOM_LVL_NORMAL].colours; sprite[zoom].colours = sprite[ZOOM_LVL_NORMAL].colours;
sprite[zoom].AllocateData(zoom, sprite[zoom].height * sprite[zoom].width); sprite[zoom].AllocateData(zoom, static_cast<size_t>(sprite[zoom].height) * sprite[zoom].width);
SpriteLoader::CommonPixel *dst = sprite[zoom].data; SpriteLoader::CommonPixel *dst = sprite[zoom].data;
const SpriteLoader::CommonPixel *src = sprite[zoom - 1].data; const SpriteLoader::CommonPixel *src = sprite[zoom - 1].data;
@@ -338,9 +338,10 @@ static bool PadSingleSprite(SpriteLoader::Sprite *sprite, ZoomLevel zoom, uint p
if (width > UINT16_MAX || height > UINT16_MAX) return false; if (width > UINT16_MAX || height > UINT16_MAX) return false;
/* Copy source data and reallocate sprite memory. */ /* Copy source data and reallocate sprite memory. */
SpriteLoader::CommonPixel *src_data = MallocT<SpriteLoader::CommonPixel>(sprite->width * sprite->height); size_t sprite_size = static_cast<size_t>(sprite->width) * sprite->height;
MemCpyT(src_data, sprite->data, sprite->width * sprite->height); SpriteLoader::CommonPixel *src_data = MallocT<SpriteLoader::CommonPixel>(sprite_size);
sprite->AllocateData(zoom, width * height); MemCpyT(src_data, sprite->data, sprite_size);
sprite->AllocateData(zoom, static_cast<size_t>(width) * height);
/* Copy with padding to destination. */ /* Copy with padding to destination. */
SpriteLoader::CommonPixel *src = src_data; SpriteLoader::CommonPixel *src = src_data;

View File

@@ -92,7 +92,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f
if (num != 0) return WarnCorruptSprite(file, file_pos, __LINE__); if (num != 0) return WarnCorruptSprite(file, file_pos, __LINE__);
sprite->AllocateData(zoom_lvl, sprite->width * sprite->height); sprite->AllocateData(zoom_lvl, static_cast<size_t>(sprite->width) * sprite->height);
/* Convert colour depth to pixel size. */ /* Convert colour depth to pixel size. */
int bpp = 0; int bpp = 0;
@@ -168,13 +168,14 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f
} while (!last_item); } while (!last_item);
} }
} else { } else {
if (dest_size < sprite->width * sprite->height * bpp) { int64 sprite_size = static_cast<int64>(sprite->width) * sprite->height * bpp;
if (dest_size < sprite_size) {
return WarnCorruptSprite(file, file_pos, __LINE__); return WarnCorruptSprite(file, file_pos, __LINE__);
} }
if (dest_size > sprite->width * sprite->height * bpp) { if (dest_size > sprite_size) {
static byte warning_level = 0; static byte warning_level = 0;
DEBUG(sprite, warning_level, "Ignoring " OTTD_PRINTF64 " unused extra bytes from the sprite from %s at position %i", dest_size - sprite->width * sprite->height * bpp, file.GetSimplifiedFilename().c_str(), (int)file_pos); DEBUG(sprite, warning_level, "Ignoring " OTTD_PRINTF64 " unused extra bytes from the sprite from %s at position %i", dest_size - sprite_size, file.GetSimplifiedFilename().c_str(), (int)file_pos);
warning_level = 6; warning_level = 6;
} }

View File

@@ -1324,7 +1324,7 @@ void GetStationLayout(byte *layout, uint numtracks, uint plat_len, const Station
!statspec->layouts[plat_len - 1][numtracks - 1].empty()) { !statspec->layouts[plat_len - 1][numtracks - 1].empty()) {
/* Custom layout defined, follow it. */ /* Custom layout defined, follow it. */
memcpy(layout, statspec->layouts[plat_len - 1][numtracks - 1].data(), memcpy(layout, statspec->layouts[plat_len - 1][numtracks - 1].data(),
plat_len * numtracks); static_cast<size_t>(plat_len) * numtracks);
return; return;
} }
@@ -2162,7 +2162,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Check if this number of road stops can be allocated. */ /* Check if this number of road stops can be allocated. */
if (!RoadStop::CanAllocateItem(roadstop_area.w * roadstop_area.h)) return_cmd_error(type ? STR_ERROR_TOO_MANY_TRUCK_STOPS : STR_ERROR_TOO_MANY_BUS_STOPS); if (!RoadStop::CanAllocateItem(static_cast<size_t>(roadstop_area.w) * roadstop_area.h)) return_cmd_error(type ? STR_ERROR_TOO_MANY_TRUCK_STOPS : STR_ERROR_TOO_MANY_BUS_STOPS);
ret = BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD); ret = BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
if (ret.Failed()) return ret; if (ret.Failed()) return ret;

View File

@@ -327,7 +327,7 @@ static inline bool AllocHeightMap()
_height_map.size_y = MapSizeY(); _height_map.size_y = MapSizeY();
/* Allocate memory block for height map row pointers */ /* Allocate memory block for height map row pointers */
size_t total_size = (_height_map.size_x + 1) * (_height_map.size_y + 1); size_t total_size = static_cast<size_t>(_height_map.size_x + 1) * (_height_map.size_y + 1);
_height_map.dim_x = _height_map.size_x + 1; _height_map.dim_x = _height_map.size_x + 1;
_height_map.h.resize(total_size); _height_map.h.resize(total_size);
@@ -581,7 +581,7 @@ static void HeightMapCurves(uint level)
float factor = sqrt((float)_height_map.size_x / (float)_height_map.size_y); float factor = sqrt((float)_height_map.size_x / (float)_height_map.size_y);
uint sx = Clamp((int)(((1 << level) * factor) + 0.5), 1, 128); uint sx = Clamp((int)(((1 << level) * factor) + 0.5), 1, 128);
uint sy = Clamp((int)(((1 << level) / factor) + 0.5), 1, 128); uint sy = Clamp((int)(((1 << level) / factor) + 0.5), 1, 128);
byte *c = AllocaM(byte, sx * sy); byte *c = AllocaM(byte, static_cast<size_t>(sx) * sy);
for (uint i = 0; i < sx * sy; i++) { for (uint i = 0; i < sx * sy; i++) {
c[i] = Random() % lengthof(curve_maps); c[i] = Random() % lengthof(curve_maps);

View File

@@ -204,7 +204,7 @@ static bool CreateMainSurface(uint w, uint h)
_screen.dst_ptr = _allegro_screen->line[0]; _screen.dst_ptr = _allegro_screen->line[0];
/* Initialise the screen so we don't blit garbage to the screen */ /* Initialise the screen so we don't blit garbage to the screen */
memset(_screen.dst_ptr, 0, _screen.height * _screen.pitch); memset(_screen.dst_ptr, 0, static_cast<size_t>(_screen.height) * _screen.pitch);
/* Set the mouse at the place where we expect it */ /* Set the mouse at the place where we expect it */
poll_mouse(); poll_mouse();

View File

@@ -140,7 +140,7 @@ const char *VideoDriver_Dedicated::Start(const StringList &parm)
this->UpdateAutoResolution(); this->UpdateAutoResolution();
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
_dedicated_video_mem = (bpp == 0) ? nullptr : MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8)); _dedicated_video_mem = (bpp == 0) ? nullptr : MallocT<byte>(static_cast<size_t>(_cur_resolution.width) * _cur_resolution.height * (bpp / 8));
_screen.width = _screen.pitch = _cur_resolution.width; _screen.width = _screen.pitch = _cur_resolution.width;
_screen.height = _cur_resolution.height; _screen.height = _cur_resolution.height;

View File

@@ -918,6 +918,7 @@ bool OpenGLBackend::Resize(int w, int h, bool force)
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
int pitch = Align(w, 4); int pitch = Align(w, 4);
size_t line_pixel_count = static_cast<size_t>(pitch) * h;
_glViewport(0, 0, w, h); _glViewport(0, 0, w, h);
@@ -928,27 +929,27 @@ bool OpenGLBackend::Resize(int w, int h, bool force)
_glDeleteBuffers(1, &this->vid_pbo); _glDeleteBuffers(1, &this->vid_pbo);
_glGenBuffers(1, &this->vid_pbo); _glGenBuffers(1, &this->vid_pbo);
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->vid_pbo); _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->vid_pbo);
_glBufferStorage(GL_PIXEL_UNPACK_BUFFER, pitch * h * bpp / 8, nullptr, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_CLIENT_STORAGE_BIT); _glBufferStorage(GL_PIXEL_UNPACK_BUFFER, line_pixel_count * bpp / 8, nullptr, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_CLIENT_STORAGE_BIT);
} else { } else {
/* Re-allocate video buffer texture and backing store. */ /* Re-allocate video buffer texture and backing store. */
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->vid_pbo); _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->vid_pbo);
_glBufferData(GL_PIXEL_UNPACK_BUFFER, pitch * h * bpp / 8, nullptr, GL_DYNAMIC_DRAW); _glBufferData(GL_PIXEL_UNPACK_BUFFER, line_pixel_count * bpp / 8, nullptr, GL_DYNAMIC_DRAW);
} }
if (bpp == 32) { if (bpp == 32) {
/* Initialize backing store alpha to opaque for 32bpp modes. */ /* Initialize backing store alpha to opaque for 32bpp modes. */
Colour black(0, 0, 0); Colour black(0, 0, 0);
if (_glClearBufferSubData != nullptr) { if (_glClearBufferSubData != nullptr) {
_glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_RGBA8, 0, pitch * h * bpp / 8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &black.data); _glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_RGBA8, 0, line_pixel_count * bpp / 8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &black.data);
} else { } else {
ClearPixelBuffer<uint32>(pitch * h, black.data); ClearPixelBuffer<uint32>(line_pixel_count, black.data);
} }
} else if (bpp == 8) { } else if (bpp == 8) {
if (_glClearBufferSubData != nullptr) { if (_glClearBufferSubData != nullptr) {
byte b = 0; byte b = 0;
_glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_R8, 0, pitch * h, GL_RED, GL_UNSIGNED_BYTE, &b); _glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_R8, 0, line_pixel_count, GL_RED, GL_UNSIGNED_BYTE, &b);
} else { } else {
ClearPixelBuffer<byte>(pitch * h, 0); ClearPixelBuffer<byte>(line_pixel_count, 0);
} }
} }
@@ -972,18 +973,18 @@ bool OpenGLBackend::Resize(int w, int h, bool force)
_glDeleteBuffers(1, &this->anim_pbo); _glDeleteBuffers(1, &this->anim_pbo);
_glGenBuffers(1, &this->anim_pbo); _glGenBuffers(1, &this->anim_pbo);
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->anim_pbo); _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->anim_pbo);
_glBufferStorage(GL_PIXEL_UNPACK_BUFFER, pitch * h, nullptr, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_CLIENT_STORAGE_BIT); _glBufferStorage(GL_PIXEL_UNPACK_BUFFER, line_pixel_count, nullptr, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_CLIENT_STORAGE_BIT);
} else { } else {
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->anim_pbo); _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->anim_pbo);
_glBufferData(GL_PIXEL_UNPACK_BUFFER, pitch * h, nullptr, GL_DYNAMIC_DRAW); _glBufferData(GL_PIXEL_UNPACK_BUFFER, line_pixel_count, nullptr, GL_DYNAMIC_DRAW);
} }
/* Initialize buffer as 0 == no remap. */ /* Initialize buffer as 0 == no remap. */
if (_glClearBufferSubData != nullptr) { if (_glClearBufferSubData != nullptr) {
byte b = 0; byte b = 0;
_glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_R8, 0, pitch * h, GL_RED, GL_UNSIGNED_BYTE, &b); _glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_R8, 0, line_pixel_count, GL_RED, GL_UNSIGNED_BYTE, &b);
} else { } else {
ClearPixelBuffer<byte>(pitch * h, 0); ClearPixelBuffer<byte>(line_pixel_count, 0);
} }
_glBindTexture(GL_TEXTURE_2D, this->anim_texture); _glBindTexture(GL_TEXTURE_2D, this->anim_texture);
@@ -1191,7 +1192,7 @@ uint8 *OpenGLBackend::GetAnimBuffer()
this->anim_buffer = _glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE); this->anim_buffer = _glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
} else if (this->anim_buffer == nullptr) { } else if (this->anim_buffer == nullptr) {
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->anim_pbo); _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->anim_pbo);
this->anim_buffer = _glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, _screen.pitch * _screen.height, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); this->anim_buffer = _glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, static_cast<GLsizeiptr>(_screen.pitch) * _screen.height, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
} }
return (uint8 *)this->anim_buffer; return (uint8 *)this->anim_buffer;
@@ -1491,8 +1492,9 @@ void OpenGLSprite::Update(uint width, uint height, uint level, const SpriteLoade
if (this->tex[TEX_RGBA] != 0) { if (this->tex[TEX_RGBA] != 0) {
/* Unpack pixel data */ /* Unpack pixel data */
Colour *rgba = buf_rgba.Allocate(width * height); size_t size = static_cast<size_t>(width) * height;
for (size_t i = 0; i < width * height; i++) { Colour *rgba = buf_rgba.Allocate(size);
for (size_t i = 0; i < size; i++) {
rgba[i].r = data[i].r; rgba[i].r = data[i].r;
rgba[i].g = data[i].g; rgba[i].g = data[i].g;
rgba[i].b = data[i].b; rgba[i].b = data[i].b;
@@ -1505,7 +1507,7 @@ void OpenGLSprite::Update(uint width, uint height, uint level, const SpriteLoade
if (this->tex[TEX_REMAP] != 0) { if (this->tex[TEX_REMAP] != 0) {
/* Unpack and align pixel data. */ /* Unpack and align pixel data. */
int pitch = Align(width, 4); size_t pitch = Align(width, 4);
uint8 *pal = buf_pal.Allocate(pitch * height); uint8 *pal = buf_pal.Allocate(pitch * height);
const SpriteLoader::CommonPixel *row = data; const SpriteLoader::CommonPixel *row = data;