Skip to content

Commit 6652b70

Browse files
committed
Fixed the algorithm for sorting the list of quests.
1 parent 27bb078 commit 6652b70

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

sfall/Modules/QuestList.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,24 @@ static void __fastcall QuestListSort(fo::QuestData* questList, size_t numElemets
448448
fo::QuestData* tmpList = new fo::QuestData[numElemets];;
449449
std::memcpy(tmpList, questList, numElemets * sizeof(fo::QuestData));
450450

451-
long locStart = 1500; // number from which the locations starting
451+
long locStart = 1500; // number message from which the locations starting
452452
size_t leftStart = 0;
453+
long locLast = 0;
454+
455+
for (size_t i = 0; i < numElemets; i++)
456+
{
457+
long loc = tmpList[i].location;
458+
if (locStart > loc) locStart = loc;
459+
if (loc > locLast) locLast = loc;
460+
}
453461

454462
for (size_t i = 0; i < numElemets;)
455463
{
456464
for (size_t j = leftStart; j < numElemets; j++)
457465
{
458466
if (!tmpList[j].location) {
459-
if ((j - leftStart) == 1) leftStart = j;
460-
continue;
467+
if ((j - leftStart) == 1) leftStart = j;
468+
continue;
461469
}
462470
if (tmpList[j].location == locStart) {
463471
// unsorted?
@@ -466,7 +474,7 @@ static void __fastcall QuestListSort(fo::QuestData* questList, size_t numElemets
466474
tmpList[j].location = 0;
467475
}
468476
}
469-
locStart++;
477+
if (++locStart > locLast) break;
470478
}
471479
delete[] tmpList;
472480
}

0 commit comments

Comments
 (0)