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

Method RemoveBottom

src/script/api/script_list.cpp:644–671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642}
643
644void ScriptList::RemoveBottom(SQInteger count)
645{
646 this->modifications++;
647
648 if (!this->sort_ascending) {
649 this->Sort(this->sorter_type, !this->sort_ascending);
650 this->RemoveTop(count);
651 this->Sort(this->sorter_type, !this->sort_ascending);
652 return;
653 }
654
655 switch (this->sorter_type) {
656 default: NOT_REACHED();
657 case SORT_BY_VALUE:
658 for (auto iter = this->values.rbegin(); iter != this->values.rend(); iter = this->values.rbegin()) {
659 if (--count < 0) return;
660 this->RemoveItem(iter->second);
661 }
662 break;
663
664 case SORT_BY_ITEM:
665 for (auto iter = this->items.rbegin(); iter != this->items.rend(); iter = this->items.rbegin()) {
666 if (--count < 0) return;
667 this->RemoveItem(iter->first);
668 }
669 break;
670 }
671}
672
673void ScriptList::RemoveList(ScriptList *list)
674{

Callers 2

RemoveTopMethod · 0.95
KeepTopMethod · 0.95

Calls 4

SortMethod · 0.95
RemoveTopMethod · 0.95
RemoveItemMethod · 0.95
NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected