MCPcopy Create free account
hub / github.com/NetHack/NetHack / sort_valuables

Function sort_valuables

src/end.c:797–818  ·  view source on GitHub ↗

* Sort collected valuables, most frequent to least. We could just * as easily use qsort, but we don't care about efficiency here. */

Source from the content-addressed store, hash-verified

795 * as easily use qsort, but we don't care about efficiency here.
796 */
797staticfn void
798sort_valuables(
799 struct valuable_data list[],
800 int size) /* max value is less than 20 */
801{
802 int i, j;
803 struct valuable_data ltmp;
804
805 /* move greater quantities to the front of the list */
806 for (i = 1; i < size; i++) {
807 if (list[i].count == 0)
808 continue; /* empty slot */
809 ltmp = list[i]; /* structure copy */
810 for (j = i; j > 0; --j) {
811 if (list[j - 1].count >= ltmp.count)
812 break;
813 list[j] = list[j - 1];
814 }
815 list[j] = ltmp;
816 }
817 return;
818}
819
820#if 0
821/*

Callers 1

really_doneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected