Changeset - r27268:0f3ade585831
[Not reviewed]
master
0 6 0
Rubidium - 13 months ago 2023-05-03 04:05:07
rubidium@openttd.org
Fix: conversion to smaller type warnings
6 files changed with 21 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -268,14 +268,19 @@ void SubtractMoneyFromCompanyFract(Compa
 
	if (cost != 0) SubtractMoneyFromAnyCompany(c, CommandCost(cst.GetExpensesType(), cost));
 
}
 

	
 
static constexpr void UpdateLandscapingLimit(uint32_t &limit, uint64_t per_64k_frames, uint64_t burst)
 
{
 
	limit = static_cast<uint32_t>(std::min<uint64_t>(limit + per_64k_frames, burst << 16));
 
}
 

	
 
/** Update the landscaping limits per company. */
 
void UpdateLandscapingLimits()
 
{
 
	for (Company *c : Company::Iterate()) {
 
		c->terraform_limit    = std::min<uint64>((uint64)c->terraform_limit    + _settings_game.construction.terraform_per_64k_frames,    (uint64)_settings_game.construction.terraform_frame_burst << 16);
 
		c->clear_limit        = std::min<uint64>((uint64)c->clear_limit        + _settings_game.construction.clear_per_64k_frames,        (uint64)_settings_game.construction.clear_frame_burst << 16);
 
		c->tree_limit         = std::min<uint64>((uint64)c->tree_limit         + _settings_game.construction.tree_per_64k_frames,         (uint64)_settings_game.construction.tree_frame_burst << 16);
 
		c->build_object_limit = std::min<uint64>((uint64)c->build_object_limit + _settings_game.construction.build_object_per_64k_frames, (uint64)_settings_game.construction.build_object_frame_burst << 16);
 
		UpdateLandscapingLimit(c->terraform_limit,    _settings_game.construction.terraform_per_64k_frames,    _settings_game.construction.terraform_frame_burst);
 
		UpdateLandscapingLimit(c->clear_limit,        _settings_game.construction.clear_per_64k_frames,        _settings_game.construction.clear_frame_burst);
 
		UpdateLandscapingLimit(c->tree_limit,         _settings_game.construction.tree_per_64k_frames,         _settings_game.construction.tree_frame_burst);
 
		UpdateLandscapingLimit(c->build_object_limit, _settings_game.construction.build_object_per_64k_frames, _settings_game.construction.build_object_frame_burst);
 
	}
 
}
 

	
src/group_gui.cpp
Show inline comments
 
@@ -606,13 +606,13 @@ public:
 

	
 
			case WID_GL_LIST_GROUP: {
 
				int y1 = r.top;
 
				int max = std::min<size_t>(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.size());
 
				for (int i = this->group_sb->GetPosition(); i < max; ++i) {
 
				size_t max = std::min<size_t>(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.size());
 
				for (size_t i = this->group_sb->GetPosition(); i < max; ++i) {
 
					const Group *g = this->groups[i];
 

	
 
					assert(g->owner == this->owner);
 

	
 
					DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * WidgetDimensions::scaled.hsep_indent, HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), g->folded || (i + 1 < (int)this->groups.size() && indents[i + 1] > this->indents[i]));
 
					DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * WidgetDimensions::scaled.hsep_indent, HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), g->folded || (i + 1 < this->groups.size() && indents[i + 1] > this->indents[i]));
 

	
 
					y1 += this->tiny_step_height;
 
				}
 
@@ -630,8 +630,8 @@ public:
 
				if (this->vli.index != ALL_GROUP && this->grouping == GB_NONE) {
 
					/* Mark vehicles which are in sub-groups (only if we are not using shared order coalescing) */
 
					Rect mr = r.WithHeight(this->resize.step_height);
 
					uint max = static_cast<uint>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()));
 
					for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
 
					size_t max = std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size());
 
					for (size_t i = this->vscroll->GetPosition(); i < max; ++i) {
 
						const Vehicle *v = this->vehgroups[i].GetSingleVehicle();
 
						if (v->group_id != this->vli.index) {
 
							GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[COLOUR_GREY][3], FILLRECT_CHECKER);
src/industry_gui.cpp
Show inline comments
 
@@ -1037,10 +1037,10 @@ public:
 
						case EA_MULTIPLIER:
 
							if (decrease) {
 
								if (i->prod_level <= PRODLEVEL_MINIMUM) return;
 
								i->prod_level = std::max<uint>(i->prod_level / 2, PRODLEVEL_MINIMUM);
 
								i->prod_level = static_cast<byte>(std::max<uint>(i->prod_level / 2, PRODLEVEL_MINIMUM));
 
							} else {
 
								if (i->prod_level >= PRODLEVEL_MAXIMUM) return;
 
								i->prod_level = std::min<uint>(i->prod_level * 2, PRODLEVEL_MAXIMUM);
 
								i->prod_level = static_cast<byte>(std::min<uint>(i->prod_level * 2, PRODLEVEL_MAXIMUM));
 
							}
 
							break;
 

	
src/spriteloader/grf.cpp
Show inline comments
 
@@ -165,7 +165,7 @@ bool DecodeSingleSprite(SpriteLoader::Sp
 
					if (colour_fmt & SCC_PAL) {
 
						switch (sprite_type) {
 
							case SpriteType::Normal: data->m = file.NeedsPaletteRemap() ? _palmap_w2d[*dest] : *dest; break;
 
							case SpriteType::Font:   data->m = std::min<uint>(*dest, 2u); break;
 
							case SpriteType::Font:   data->m = std::min<byte>(*dest, 2u); break;
 
							default:        data->m = *dest; break;
 
						}
 
						/* Magic blue. */
 
@@ -202,7 +202,7 @@ bool DecodeSingleSprite(SpriteLoader::Sp
 
			if (colour_fmt & SCC_PAL) {
 
				switch (sprite_type) {
 
					case SpriteType::Normal: sprite->data[i].m = file.NeedsPaletteRemap() ? _palmap_w2d[*pixel] : *pixel; break;
 
					case SpriteType::Font:   sprite->data[i].m = std::min<uint>(*pixel, 2u); break;
 
					case SpriteType::Font:   sprite->data[i].m = std::min<byte>(*pixel, 2u); break;
 
					default:        sprite->data[i].m = *pixel; break;
 
				}
 
				/* Magic blue. */
src/station_gui.cpp
Show inline comments
 
@@ -432,7 +432,7 @@ public:
 

	
 
			case WID_STL_LIST: {
 
				bool rtl = _current_text_dir == TD_RTL;
 
				int max = std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
 
				size_t max = std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 
				uint line_height = this->GetWidget<NWidgetBase>(widget)->resize_y;
 
				/* Spacing between station name and first rating graph. */
 
@@ -440,7 +440,7 @@ public:
 
				/* Spacing between additional rating graphs. */
 
				int rating_spacing = WidgetDimensions::scaled.hsep_normal;
 

	
 
				for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
 
				for (size_t i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
 
					const Station *st = this->stations[i];
 
					assert(st->xy != INVALID_TILE);
 

	
src/tgp.cpp
Show inline comments
 
@@ -820,7 +820,7 @@ static void HeightMapSmoothCoastInDirect
 
	 * Soften the coast slope */
 
	for (depth = 0; IsValidXY(x, y) && depth <= max_coast_Smooth_depth; depth++, x += dir_x, y += dir_y) {
 
		h = _height_map.height(x, y);
 
		h = std::min<uint>(h, h_prev + (4 + depth)); // coast softening formula
 
		h = static_cast<Height>(std::min<uint>(h, h_prev + (4 + depth))); // coast softening formula
 
		_height_map.height(x, y) = h;
 
		h_prev = h;
 
	}
0 comments (0 inline, 0 general)