MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / RemoveTop

Method RemoveTop

src/script/api/script_list.cpp:615–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615void ScriptList::RemoveTop(SQInteger count)
616{
617 this->modifications++;
618
619 if (!this->sort_ascending) {
620 this->Sort(this->sorter_type, !this->sort_ascending);
621 this->RemoveBottom(count);
622 this->Sort(this->sorter_type, !this->sort_ascending);
623 return;
624 }
625
626 switch (this->sorter_type) {
627 default: NOT_REACHED();
628 case SORT_BY_VALUE:
629 for (auto iter = this->values.begin(); iter != this->values.end(); iter = this->values.begin()) {
630 if (--count < 0) return;
631 this->RemoveItem(iter->second);
632 }
633 break;
634
635 case SORT_BY_ITEM:
636 for (auto iter = this->items.begin(); iter != this->items.end(); iter = this->items.begin()) {
637 if (--count < 0) return;
638 this->RemoveItem(iter->first);
639 }
640 break;
641 }
642}
643
644void ScriptList::RemoveBottom(SQInteger count)
645{

Callers 2

RemoveBottomMethod · 0.95
KeepBottomMethod · 0.95

Calls 6

SortMethod · 0.95
RemoveBottomMethod · 0.95
RemoveItemMethod · 0.95
NOT_REACHEDFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected