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

Method Sort

src/script/api/script_list.cpp:512–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510}
511
512void ScriptList::Sort(SorterType sorter, bool ascending)
513{
514 this->modifications++;
515
516 if (sorter != SORT_BY_VALUE && sorter != SORT_BY_ITEM) return;
517 if (sorter == this->sorter_type && ascending == this->sort_ascending) return;
518
519 switch (sorter) {
520 case SORT_BY_ITEM:
521 if (ascending) {
522 this->sorter = std::make_unique<ScriptListSorterItemAscending>(this);
523 } else {
524 this->sorter = std::make_unique<ScriptListSorterItemDescending>(this);
525 }
526 break;
527
528 case SORT_BY_VALUE:
529 if (ascending) {
530 this->sorter = std::make_unique<ScriptListSorterValueAscending>(this);
531 } else {
532 this->sorter = std::make_unique<ScriptListSorterValueDescending>(this);
533 }
534 break;
535
536 default: NOT_REACHED();
537 }
538 this->sorter_type = sorter;
539 this->sort_ascending = ascending;
540 this->initialized = false;
541}
542
543void ScriptList::AddList(ScriptList *list)
544{

Callers 7

LoadObjectMethod · 0.95
CopyListMethod · 0.95
RemoveTopMethod · 0.95
RemoveBottomMethod · 0.95
SortContentListMethod · 0.45
SortNetworkGameListMethod · 0.45

Calls 1

NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected