mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
Codechange: replace x.size() != 0 with !x.empty()
This commit is contained in:
parent
f16399f4c9
commit
37f84b7372
@ -222,7 +222,7 @@ class ReplaceVehicleWindow : public Window {
|
|||||||
/* We need to rebuild the left engines list */
|
/* We need to rebuild the left engines list */
|
||||||
this->GenerateReplaceVehList(true);
|
this->GenerateReplaceVehList(true);
|
||||||
this->vscroll[0]->SetCount(this->engines[0].size());
|
this->vscroll[0]->SetCount(this->engines[0].size());
|
||||||
if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].size() != 0) {
|
if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && !this->engines[0].empty()) {
|
||||||
this->sel_engine[0] = this->engines[0][0].engine_id;
|
this->sel_engine[0] = this->engines[0][0].engine_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -810,7 +810,7 @@ struct DepotWindow : Window {
|
|||||||
|
|
||||||
case WID_D_SELL_ALL:
|
case WID_D_SELL_ALL:
|
||||||
/* Only open the confirmation window if there are anything to sell */
|
/* Only open the confirmation window if there are anything to sell */
|
||||||
if (this->vehicle_list.size() != 0 || this->wagon_list.size() != 0) {
|
if (!this->vehicle_list.empty() || !this->wagon_list.empty()) {
|
||||||
SetDParam(0, this->type);
|
SetDParam(0, this->type);
|
||||||
SetDParam(1, this->GetDepotIndex());
|
SetDParam(1, this->GetDepotIndex());
|
||||||
ShowQuery(
|
ShowQuery(
|
||||||
|
@ -132,7 +132,7 @@ ICUParagraphLayout::ICUVisualRun::ICUVisualRun(const ICURun &run, int x) :
|
|||||||
glyphs(run.glyphs), glyph_to_char(run.glyph_to_char), total_advance(run.total_advance), font(run.font)
|
glyphs(run.glyphs), glyph_to_char(run.glyph_to_char), total_advance(run.total_advance), font(run.font)
|
||||||
{
|
{
|
||||||
/* If there are no positions, the ICURun was not Shaped; that should never happen. */
|
/* If there are no positions, the ICURun was not Shaped; that should never happen. */
|
||||||
assert(run.positions.size() != 0);
|
assert(!run.positions.empty());
|
||||||
this->positions.reserve(run.positions.size());
|
this->positions.reserve(run.positions.size());
|
||||||
|
|
||||||
/* "positions" is an array of x/y. So we need to alternate. */
|
/* "positions" is an array of x/y. So we need to alternate. */
|
||||||
|
@ -960,7 +960,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_MANAGE_VEHICLES_DROPDOWN:
|
case WID_GL_MANAGE_VEHICLES_DROPDOWN:
|
||||||
assert(this->vehicles.size() != 0);
|
assert(!this->vehicles.empty());
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case ADI_REPLACE: // Replace window
|
case ADI_REPLACE: // Replace window
|
||||||
|
@ -50,7 +50,7 @@ bool NetworkUDPSocketHandler::Listen()
|
|||||||
addr.Listen(SOCK_DGRAM, &this->sockets);
|
addr.Listen(SOCK_DGRAM, &this->sockets);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->sockets.size() != 0;
|
return !this->sockets.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ static uint8_t *_chatmessage_backup = nullptr; ///< Backup in case text is moved
|
|||||||
*/
|
*/
|
||||||
static inline bool HaveChatMessages(bool show_all)
|
static inline bool HaveChatMessages(bool show_all)
|
||||||
{
|
{
|
||||||
if (show_all) return _chatmsg_list.size() != 0;
|
if (show_all) return !_chatmsg_list.empty();
|
||||||
|
|
||||||
auto now = std::chrono::steady_clock::now();
|
auto now = std::chrono::steady_clock::now();
|
||||||
for (auto &cmsg : _chatmsg_list) {
|
for (auto &cmsg : _chatmsg_list) {
|
||||||
|
@ -9069,7 +9069,7 @@ static void CalculateRefitMasks()
|
|||||||
/* Figure out which CTT to use for the default cargo, if it is 'first refittable'. */
|
/* Figure out which CTT to use for the default cargo, if it is 'first refittable'. */
|
||||||
const GRFFile *file = _gted[engine].defaultcargo_grf;
|
const GRFFile *file = _gted[engine].defaultcargo_grf;
|
||||||
if (file == nullptr) file = e->GetGRF();
|
if (file == nullptr) file = e->GetGRF();
|
||||||
if (file != nullptr && file->grf_version >= 8 && file->cargo_list.size() != 0) {
|
if (file != nullptr && file->grf_version >= 8 && !file->cargo_list.empty()) {
|
||||||
/* Use first refittable cargo from cargo translation table */
|
/* Use first refittable cargo from cargo translation table */
|
||||||
byte best_local_slot = UINT8_MAX;
|
byte best_local_slot = UINT8_MAX;
|
||||||
for (CargoID cargo_type : SetCargoBitIterator(ei->refit_mask)) {
|
for (CargoID cargo_type : SetCargoBitIterator(ei->refit_mask)) {
|
||||||
|
@ -163,7 +163,7 @@ struct NewGRFParametersWindow : public Window {
|
|||||||
clicked_row(UINT_MAX),
|
clicked_row(UINT_MAX),
|
||||||
editable(editable)
|
editable(editable)
|
||||||
{
|
{
|
||||||
this->action14present = (c->num_valid_params != c->param.size() || c->param_info.size() != 0);
|
this->action14present = (c->num_valid_params != c->param.size() || !c->param_info.empty());
|
||||||
|
|
||||||
this->CreateNestedTree();
|
this->CreateNestedTree();
|
||||||
this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR);
|
||||||
|
@ -594,7 +594,7 @@ char *strcasestr(const char *haystack, const char *needle)
|
|||||||
*/
|
*/
|
||||||
static std::string_view SkipGarbage(std::string_view str)
|
static std::string_view SkipGarbage(std::string_view str)
|
||||||
{
|
{
|
||||||
while (str.size() != 0 && (str[0] < '0' || IsInsideMM(str[0], ';', '@' + 1) || IsInsideMM(str[0], '[', '`' + 1) || IsInsideMM(str[0], '{', '~' + 1))) str.remove_prefix(1);
|
while (!str.empty() && (str[0] < '0' || IsInsideMM(str[0], ';', '@' + 1) || IsInsideMM(str[0], '[', '`' + 1) || IsInsideMM(str[0], '{', '~' + 1))) str.remove_prefix(1);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2080,7 +2080,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_VL_MANAGE_VEHICLES_DROPDOWN:
|
case WID_VL_MANAGE_VEHICLES_DROPDOWN:
|
||||||
assert(this->vehicles.size() != 0);
|
assert(!this->vehicles.empty());
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case ADI_REPLACE: // Replace window
|
case ADI_REPLACE: // Replace window
|
||||||
|
@ -1747,7 +1747,7 @@ void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom
|
|||||||
|
|
||||||
DrawTextEffects(&_vd.dpi);
|
DrawTextEffects(&_vd.dpi);
|
||||||
|
|
||||||
if (_vd.tile_sprites_to_draw.size() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw);
|
if (!_vd.tile_sprites_to_draw.empty()) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw);
|
||||||
|
|
||||||
for (auto &psd : _vd.parent_sprites_to_draw) {
|
for (auto &psd : _vd.parent_sprites_to_draw) {
|
||||||
_vd.parent_sprites_to_sort.push_back(&psd);
|
_vd.parent_sprites_to_sort.push_back(&psd);
|
||||||
@ -1773,7 +1773,7 @@ void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom
|
|||||||
vp->overlay->Draw(&dp);
|
vp->overlay->Draw(&dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_vd.string_sprites_to_draw.size() != 0) {
|
if (!_vd.string_sprites_to_draw.empty()) {
|
||||||
/* translate to world coordinates */
|
/* translate to world coordinates */
|
||||||
dp.left = UnScaleByZoom(_vd.dpi.left, zoom);
|
dp.left = UnScaleByZoom(_vd.dpi.left, zoom);
|
||||||
dp.top = UnScaleByZoom(_vd.dpi.top, zoom);
|
dp.top = UnScaleByZoom(_vd.dpi.top, zoom);
|
||||||
|
Loading…
Reference in New Issue
Block a user