Fix various possible integer type conversion issues
This commit is contained in:
@@ -45,7 +45,7 @@ void Blitter_40bppAnim::SetPixel32(void *video, int x, int y, uint8 colour, uint
|
||||
} else {
|
||||
*((Colour *)video + x + y * _screen.pitch) = colour32;
|
||||
|
||||
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * _screen.pitch] = 0;
|
||||
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + (ssize_t)y * _screen.pitch] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -375,7 +375,7 @@ public:
|
||||
void RemoveEdge(NodeID from, NodeID to);
|
||||
|
||||
inline uint64 CalculateCostEstimate() const {
|
||||
uint64 size_squared = this->Size() * this->Size();
|
||||
uint64 size_squared = (uint32)this->Size() * (uint32)this->Size();
|
||||
return size_squared * FindLastBit(size_squared * size_squared); // N^2 * 4log_2(N)
|
||||
}
|
||||
|
||||
|
@@ -68,7 +68,7 @@ static void Load_MAPT()
|
||||
|
||||
static void Check_MAPH_common()
|
||||
{
|
||||
if (_sl_maybe_chillpp && (SlGetFieldLength() == 0 || SlGetFieldLength() == _map_dim_x * _map_dim_y * 2)) {
|
||||
if (_sl_maybe_chillpp && (SlGetFieldLength() == 0 || SlGetFieldLength() == (size_t)_map_dim_x * (size_t)_map_dim_y * 2)) {
|
||||
_sl_maybe_chillpp = false;
|
||||
extern void SlXvChillPPSpecialSavegameVersions();
|
||||
SlXvChillPPSpecialSavegameVersions();
|
||||
|
@@ -345,7 +345,7 @@ static void Load_TOWN()
|
||||
uint16 w = SlReadUint16();
|
||||
uint16 h = SlReadUint16();
|
||||
if (w != 0) {
|
||||
SlSkipBytes((SlXvIsFeaturePresent(XSLFI_TOWN_CARGO_MATRIX) ? 8 : 4) * (w / 4 * h / 4));
|
||||
SlSkipBytes((SlXvIsFeaturePresent(XSLFI_TOWN_CARGO_MATRIX) ? 8 : 4) * ((uint)(w / 4) * (uint)(h / 4)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -191,7 +191,7 @@ TemplateVehicle* TemplateVehicleFromVirtualTrain(Train *virt)
|
||||
|
||||
Train *init_virt = virt;
|
||||
|
||||
TemplateVehicle *tmp;
|
||||
TemplateVehicle *tmp = nullptr;
|
||||
TemplateVehicle *prev = nullptr;
|
||||
for (; virt; virt = virt->Next()) {
|
||||
tmp = new TemplateVehicle(virt->engine_type);
|
||||
|
@@ -7319,7 +7319,7 @@ int GetTrainRealisticAccelerationAtSpeed(const int speed, const int mass, const
|
||||
if (!maglev) {
|
||||
/* Static resistance plus rolling friction. */
|
||||
resistance = 10 * mass;
|
||||
resistance += mass * (15 * (512 + speed) / 512);
|
||||
resistance += (int64)mass * (int64)(15 * (512 + speed) / 512);
|
||||
}
|
||||
|
||||
const int area = 14;
|
||||
|
@@ -1348,7 +1348,7 @@ CommandCost CmdTemplateVehicleFromTrain(TileIndex tile, DoCommandFlag flags, uin
|
||||
bool should_execute = (flags & DC_EXEC) != 0;
|
||||
|
||||
if (should_execute) {
|
||||
TemplateVehicle *tmp;
|
||||
TemplateVehicle *tmp = nullptr;
|
||||
TemplateVehicle *prev = nullptr;
|
||||
for (; clicked != nullptr; clicked = clicked->Next()) {
|
||||
tmp = new TemplateVehicle(clicked->engine_type);
|
||||
|
@@ -3993,12 +3993,12 @@ void UpdateViewportSizeZoom(Viewport *vp)
|
||||
UpdateViewportDirtyBlockLeftMargin(vp);
|
||||
if (vp->zoom >= ZOOM_LVL_DRAW_MAP) {
|
||||
memset(vp->map_draw_vehicles_cache.done_hash_bits, 0, sizeof(vp->map_draw_vehicles_cache.done_hash_bits));
|
||||
vp->map_draw_vehicles_cache.vehicle_pixels.assign(vp->width * vp->height, false);
|
||||
vp->map_draw_vehicles_cache.vehicle_pixels.assign(vp->ScreenArea(), false);
|
||||
|
||||
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 32) {
|
||||
vp->land_pixel_cache.assign(vp->height * vp->width * 4, 0xD7);
|
||||
vp->land_pixel_cache.assign(vp->ScreenArea() * 4, 0xD7);
|
||||
} else {
|
||||
vp->land_pixel_cache.assign(vp->height * vp->width, 0xD7);
|
||||
vp->land_pixel_cache.assign(vp->ScreenArea(), 0xD7);
|
||||
}
|
||||
} else {
|
||||
vp->map_draw_vehicles_cache.vehicle_pixels.clear();
|
||||
@@ -4108,7 +4108,7 @@ void MarkViewportDirty(Viewport * const vp, int left, int top, int right, int bo
|
||||
uint bitdepth = BlitterFactory::GetCurrentBlitter()->GetScreenDepth() / 8;
|
||||
uint8 *land_cache = vp->land_pixel_cache.data() + ((l + (t * vp->width)) * bitdepth);
|
||||
while (--h) {
|
||||
memset(land_cache, 0xD7, w * bitdepth);
|
||||
memset(land_cache, 0xD7, (size_t)w * bitdepth);
|
||||
land_cache += vp->width * bitdepth;
|
||||
}
|
||||
}
|
||||
|
@@ -79,6 +79,11 @@ struct Viewport {
|
||||
this->update_vehicles = false;
|
||||
}
|
||||
|
||||
size_t ScreenArea() const
|
||||
{
|
||||
return ((size_t)this->width) * ((size_t)this->height);
|
||||
}
|
||||
|
||||
private:
|
||||
uint GetDirtyBlockShift() const
|
||||
{
|
||||
|
Reference in New Issue
Block a user