diff --git a/sfall/Modules/QuestList.cpp b/sfall/Modules/QuestList.cpp index 3cf60542..8304fa81 100644 --- a/sfall/Modules/QuestList.cpp +++ b/sfall/Modules/QuestList.cpp @@ -447,8 +447,15 @@ static void __fastcall QuestListSort(fo::QuestData* questList, size_t numElement fo::QuestData* tmpList = new fo::QuestData[numElements]; std::memcpy(tmpList, questList, numElements * sizeof(fo::QuestData)); - long locStart = 1500; // number from which the locations starting + long locStart = 1500; // message number from which the locations starting size_t leftStart = 0; + long locLast = 0; + + for (size_t i = 0; i < numElements; i++) { + long loc = tmpList[i].location; + if (locStart > loc) locStart = loc; + if (loc > locLast) locLast = loc; + } for (size_t i = 0; i < numElements;) { for (size_t j = leftStart; j < numElements; j++) { @@ -463,7 +470,7 @@ static void __fastcall QuestListSort(fo::QuestData* questList, size_t numElement tmpList[j].location = 0; } } - locStart++; + if (++locStart > locLast) break; } delete[] tmpList; }