Skip to content

Commit

Permalink
Fixed SetThreadDescription, added new sort
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Jan 21, 2024
1 parent c133796 commit 6a22e52
Show file tree
Hide file tree
Showing 9 changed files with 561 additions and 6 deletions.
1 change: 1 addition & 0 deletions Sources/Jazz2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@
<ClInclude Include="nCine\Base\ParallelHashMap\phmap_config.h" />
<ClInclude Include="nCine\Base\ParallelHashMap\phmap_fwd_decl.h" />
<ClInclude Include="nCine\Base\ParallelHashMap\phmap_utils.h" />
<ClInclude Include="nCine\Base\pdqsort\pdqsort.h" />
<ClInclude Include="nCine\Base\Random.h" />
<ClInclude Include="nCine\Base\ReverseIterator.h" />
<ClInclude Include="nCine\Base\StaticHashMap.h" />
Expand Down
6 changes: 6 additions & 0 deletions Sources/Jazz2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
<Filter Include="Source Files\Jazz2\Actors\Multiplayer">
<UniqueIdentifier>{5a410bc7-e012-4efc-a75b-41bf6b0e9771}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\nCine\Base\pdqsort">
<UniqueIdentifier>{a72d645b-36b7-485e-b3f6-5ec77cbd0ee2}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Resources.h">
Expand Down Expand Up @@ -1464,6 +1467,9 @@
<ClInclude Include="Jazz2\UI\Menu\FirstRunSection.h">
<Filter>Header Files\Jazz2\UI\Menu</Filter>
</ClInclude>
<ClInclude Include="nCine\Base\pdqsort\pdqsort.h">
<Filter>Header Files\nCine\Base\pdqsort</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/ContentResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ namespace Jazz2
}

// Animation states must be sorted, so binary search can be used
std::sort(metadata->Animations.begin(), metadata->Animations.end());
sort(metadata->Animations.begin(), metadata->Animations.end());
}

if (!_isHeadless) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/Menu/CustomLevelSelectSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ namespace Jazz2::UI::Menu
return;
}

std::sort(_items.begin(), _items.end(), [](const ItemData& a, const ItemData& b) -> bool {
sort(_items.begin(), _items.end(), [](const ItemData& a, const ItemData& b) -> bool {
return (a.LevelName < b.LevelName);
});
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Jazz2::UI::Menu
AddEpisode(item);
}

std::sort(_items.begin(), _items.end(), [](const ListViewItem& a, const ListViewItem& b) -> bool {
sort(_items.begin(), _items.end(), [](const ListViewItem& a, const ListViewItem& b) -> bool {
return (a.Item.Description.Position < b.Item.Description.Position);
});
}
Expand Down
21 changes: 21 additions & 0 deletions Sources/nCine/Base/Algorithms.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "Iterator.h"
#include "pdqsort/pdqsort.h"

#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -314,6 +315,26 @@ namespace nCine
return n;
}

template<class Iter, class Compare>
inline void sort(Iter begin, Iter end, Compare comp)
{
#if defined(PREFER_STD_SORT)
std::sort(begin, end, comp);
#else
pdqsort(begin, end, comp);
#endif
}

template<class Iter>
inline void sort(Iter begin, Iter end)
{
#if defined(PREFER_STD_SORT)
std::sort(begin, end);
#else
pdqsort(begin, end);
#endif
}

float halfToFloat(std::uint16_t value);
std::uint16_t floatToHalf(float value);

Expand Down
Loading

0 comments on commit 6a22e52

Please sign in to comment.