mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: replace x.size() > 0 with !x.empty()
This commit is contained in:
parent
c9276c2959
commit
f16399f4c9
|
@ -763,7 +763,7 @@ static SQInteger closure_getinfos(HSQUIRRELVM v) {
|
|||
res->NewSlot(SQString::Create(_ss(v),"name",-1),nc->_name);
|
||||
res->NewSlot(SQString::Create(_ss(v),"paramscheck",-1),nc->_nparamscheck);
|
||||
SQObjectPtr typecheck;
|
||||
if(nc->_typecheck.size() > 0) {
|
||||
if(!nc->_typecheck.empty()) {
|
||||
typecheck =
|
||||
SQArray::Create(_ss(v), nc->_typecheck.size());
|
||||
for(SQUnsignedInteger n = 0; n<nc->_typecheck.size(); n++) {
|
||||
|
|
|
@ -564,7 +564,7 @@ void SQFuncState::PopChildState()
|
|||
|
||||
SQFuncState::~SQFuncState()
|
||||
{
|
||||
while(_childstates.size() > 0)
|
||||
while(!_childstates.empty())
|
||||
{
|
||||
PopChildState();
|
||||
}
|
||||
|
|
|
@ -1008,7 +1008,7 @@ public:
|
|||
this->groups.ForceRebuild();
|
||||
this->BuildGroupList((CompanyID)this->window_number);
|
||||
|
||||
if (this->groups.size() > 0) {
|
||||
if (!this->groups.empty()) {
|
||||
this->sel = this->groups[0]->index;
|
||||
}
|
||||
}
|
||||
|
@ -1095,7 +1095,7 @@ public:
|
|||
|
||||
if (!Group::IsValidID(this->sel)) {
|
||||
this->sel = INVALID_GROUP;
|
||||
if (this->groups.size() > 0) this->sel = this->groups[0]->index;
|
||||
if (!this->groups.empty()) this->sel = this->groups[0]->index;
|
||||
}
|
||||
|
||||
this->SetDirty();
|
||||
|
|
|
@ -139,7 +139,7 @@ void DumpTarget::BeginStruct(size_t type_id, const std::string &name, const void
|
|||
{
|
||||
/* make composite name */
|
||||
std::string cur_name = GetCurrentStructName();
|
||||
if (cur_name.size() > 0) {
|
||||
if (!cur_name.empty()) {
|
||||
/* add name delimiter (we use structured names) */
|
||||
cur_name += ".";
|
||||
}
|
||||
|
|
|
@ -939,14 +939,14 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
|||
|
||||
/* Calculate download size for the instrument. */
|
||||
size_t i_size = sizeof(DMUS_DOWNLOADINFO) + sizeof(DMUS_INSTRUMENT);
|
||||
if (dls_file.instruments[i].articulators.size() > 0) {
|
||||
if (!dls_file.instruments[i].articulators.empty()) {
|
||||
/* Articulations are stored as two chunks, one containing meta data and one with the actual articulation data. */
|
||||
offsets += 2;
|
||||
i_size += sizeof(DMUS_ARTICULATION2) + sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * dls_file.instruments[i].articulators.size();
|
||||
}
|
||||
|
||||
for (std::vector<DLSFile::DLSRegion>::iterator rgn = dls_file.instruments[i].regions.begin(); rgn != dls_file.instruments[i].regions.end(); rgn++) {
|
||||
if (rgn->articulators.size() > 0) {
|
||||
if (!rgn->articulators.empty()) {
|
||||
offsets += 2;
|
||||
i_size += sizeof(DMUS_ARTICULATION2) + sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * rgn->articulators.size();
|
||||
}
|
||||
|
@ -999,7 +999,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
|||
instrument = inst_data + 1;
|
||||
|
||||
/* Write global articulations. */
|
||||
if (dls_file.instruments[i].articulators.size() > 0) {
|
||||
if (!dls_file.instruments[i].articulators.empty()) {
|
||||
inst_data->ulGlobalArtIdx = last_offset;
|
||||
offset_table[last_offset++] = (char *)instrument - inst_base;
|
||||
offset_table[last_offset++] = (char *)instrument + sizeof(DMUS_ARTICULATION2) - inst_base;
|
||||
|
@ -1028,18 +1028,18 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
|||
/* The wave sample data will be taken from the region, if defined, otherwise from the wave itself. */
|
||||
if (rgn.wave_sample.cbSize != 0) {
|
||||
inst_region->WSMP = rgn.wave_sample;
|
||||
if (rgn.wave_loops.size() > 0) MemCpyT(inst_region->WLOOP, &rgn.wave_loops.front(), rgn.wave_loops.size());
|
||||
if (!rgn.wave_loops.empty()) MemCpyT(inst_region->WLOOP, &rgn.wave_loops.front(), rgn.wave_loops.size());
|
||||
|
||||
instrument = (char *)(inst_region + 1) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * rgn.wave_loops.size();
|
||||
} else {
|
||||
inst_region->WSMP = rgn.wave_sample;
|
||||
if (dls_file.waves[wave_id].wave_loops.size() > 0) MemCpyT(inst_region->WLOOP, &dls_file.waves[wave_id].wave_loops.front(), dls_file.waves[wave_id].wave_loops.size());
|
||||
if (!dls_file.waves[wave_id].wave_loops.empty()) MemCpyT(inst_region->WLOOP, &dls_file.waves[wave_id].wave_loops.front(), dls_file.waves[wave_id].wave_loops.size());
|
||||
|
||||
instrument = (char *)(inst_region + 1) - sizeof(DMUS_REGION::WLOOP) + sizeof(WLOOP) * dls_file.waves[wave_id].wave_loops.size();
|
||||
}
|
||||
|
||||
/* Write local articulator data. */
|
||||
if (rgn.articulators.size() > 0) {
|
||||
if (!rgn.articulators.empty()) {
|
||||
inst_region->ulRegionArtIdx = last_offset;
|
||||
offset_table[last_offset++] = (char *)instrument - inst_base;
|
||||
offset_table[last_offset++] = (char *)instrument + sizeof(DMUS_ARTICULATION2) - inst_base;
|
||||
|
@ -1168,7 +1168,7 @@ void MusicDriver_DMusic::Stop()
|
|||
}
|
||||
|
||||
/* Unloaded any instruments we loaded. */
|
||||
if (_dls_downloads.size() > 0) {
|
||||
if (!_dls_downloads.empty()) {
|
||||
IDirectMusicPortDownload *download_port = nullptr;
|
||||
_port->QueryInterface(IID_IDirectMusicPortDownload, (LPVOID *)&download_port);
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
*/
|
||||
bool IsValid() const
|
||||
{
|
||||
return this->buf.size() > 0;
|
||||
return !this->buf.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -824,7 +824,7 @@ public:
|
|||
case WID_NCL_NAME:
|
||||
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
|
||||
this->content.ToggleSortOrder();
|
||||
if (this->content.size() > 0) this->list_pos = (int)this->content.size() - this->list_pos - 1;
|
||||
if (!this->content.empty()) this->list_pos = (int)this->content.size() - this->list_pos - 1;
|
||||
} else {
|
||||
this->content.SetSortType(widget - WID_NCL_CHECKBOX);
|
||||
this->content.ForceResort();
|
||||
|
|
|
@ -5240,7 +5240,7 @@ static void NewSpriteGroup(ByteReader *buf)
|
|||
}
|
||||
|
||||
group->default_group = GetGroupFromGroupID(setid, type, buf->ReadWord());
|
||||
group->error_group = ranges.size() > 0 ? ranges[0].group : group->default_group;
|
||||
group->error_group = ranges.empty() ? group->default_group : ranges[0].group;
|
||||
/* nvar == 0 is a special case -- we turn our value into a callback result */
|
||||
group->calculated_result = ranges.empty();
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ CargoID GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
|
|||
|
||||
/* Other cases use (possibly translated) cargobits */
|
||||
|
||||
if (grffile->cargo_list.size() > 0) {
|
||||
if (!grffile->cargo_list.empty()) {
|
||||
/* ...and the cargo is in bounds, then get the cargo ID for
|
||||
* the label */
|
||||
if (cargo < grffile->cargo_list.size()) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
|
||||
|
|
|
@ -367,7 +367,7 @@ int MacOSStringCompare(std::string_view s1, std::string_view s2)
|
|||
/* Query CoreText for word and cluster break information. */
|
||||
this->str_info.resize(utf16_to_utf8.size());
|
||||
|
||||
if (utf16_str.size() > 0) {
|
||||
if (!utf16_str.empty()) {
|
||||
CFAutoRelease<CFStringRef> str(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, &utf16_str[0], utf16_str.size(), kCFAllocatorNull));
|
||||
|
||||
/* Get cluster breaks. */
|
||||
|
|
|
@ -550,11 +550,11 @@ const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() con
|
|||
/* Query Uniscribe for word and cluster break information. */
|
||||
this->str_info.resize(utf16_to_utf8.size());
|
||||
|
||||
if (utf16_str.size() > 0) {
|
||||
if (!utf16_str.empty()) {
|
||||
/* Itemize string into language runs. */
|
||||
std::vector<SCRIPT_ITEM> runs = UniscribeItemizeString(&utf16_str[0], (int32_t)utf16_str.size());
|
||||
|
||||
for (std::vector<SCRIPT_ITEM>::const_iterator run = runs.begin(); runs.size() > 0 && run != runs.end() - 1; run++) {
|
||||
for (std::vector<SCRIPT_ITEM>::const_iterator run = runs.begin(); !runs.empty() && run != runs.end() - 1; run++) {
|
||||
/* Get information on valid word and character break.s */
|
||||
int len = (run + 1)->iCharPos - run->iCharPos;
|
||||
std::vector<SCRIPT_LOGATTR> attr(len);
|
||||
|
|
|
@ -877,7 +877,7 @@ public:
|
|||
if (!_story_page_pool.IsValidID(this->selected_page_id)) {
|
||||
this->selected_page_id = INVALID_STORY_PAGE;
|
||||
}
|
||||
if (this->selected_page_id == INVALID_STORY_PAGE && this->story_pages.size() > 0) {
|
||||
if (this->selected_page_id == INVALID_STORY_PAGE && !this->story_pages.empty()) {
|
||||
/* No page is selected, but there exist at least one available.
|
||||
* => Select first page.
|
||||
*/
|
||||
|
|
|
@ -476,7 +476,7 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t
|
|||
|
||||
byte ret_refit_cyc = 0;
|
||||
bool success = false;
|
||||
if (subtypes.size() > 0) {
|
||||
if (!subtypes.empty()) {
|
||||
/* Check whether any articulated part is refittable to 'dest_cargo_type' with a subtype listed in 'subtypes' */
|
||||
for (Vehicle *v = v_for; v != nullptr; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr) {
|
||||
const Engine *e = v->GetEngine();
|
||||
|
|
|
@ -134,7 +134,7 @@ struct DropdownWindow : Window {
|
|||
DropdownWindow(Window *parent, DropDownList &&list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll)
|
||||
: Window(&_dropdown_desc), list(std::move(list))
|
||||
{
|
||||
assert(this->list.size() > 0);
|
||||
assert(!this->list.empty());
|
||||
|
||||
this->position = position;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static const int SLIDER_WIDTH = 3;
|
|||
void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map<int, StringID> &labels)
|
||||
{
|
||||
/* Allow space for labels. We assume they are in the small font. */
|
||||
if (labels.size() > 0) r.bottom -= FONT_HEIGHT_SMALL + WidgetDimensions::scaled.hsep_normal;
|
||||
if (!labels.empty()) r.bottom -= FONT_HEIGHT_SMALL + WidgetDimensions::scaled.hsep_normal;
|
||||
|
||||
max_value -= min_value;
|
||||
|
||||
|
|
Loading…
Reference in New Issue