Skip to content

Commit a1940e9

Browse files
committed
Revert "Add high-performance, carefully engineered allocator (Addendum to 5dc09d9)"
This reverts commit 068e26b.
1 parent 068e26b commit a1940e9

File tree

7 files changed

+333
-1276
lines changed

7 files changed

+333
-1276
lines changed

Client/core/CSettings.cpp

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*****************************************************************************/
1111

1212
#include "StdInc.h"
13+
#include <algorithm>
14+
#include <vector>
1315
#include <core/CClientCommands.h>
1416
#include <game/CGame.h>
1517
#include <game/CSettings.h>
@@ -1147,7 +1149,6 @@ void CSettings::CreateGUI()
11471149
m_pDebugSettingCombo->AddItem("#0000 Lua trace")->SetData((void*)EDiagnosticDebug::LUA_TRACE_0000);
11481150
m_pDebugSettingCombo->AddItem("#0000 Resize always")->SetData((void*)EDiagnosticDebug::RESIZE_ALWAYS_0000);
11491151
m_pDebugSettingCombo->AddItem("#0000 Resize never")->SetData((void*)EDiagnosticDebug::RESIZE_NEVER_0000);
1150-
m_pDebugSettingCombo->AddItem("#0000 Memory allocation debug")->SetData((void*)EDiagnosticDebug::BAD_ALLOC);
11511152
m_pDebugSettingCombo->SetReadOnly(true);
11521153
vecTemp.fY += fLineHeight;
11531154

@@ -1693,6 +1694,15 @@ void CSettings::UpdateVideoTab()
16931694
m_pPlayerMapImageCombo->SetSelectedItemByIndex(iVar);
16941695
}
16951696

1697+
struct ResolutionData
1698+
{
1699+
int width;
1700+
int height;
1701+
int depth;
1702+
int vidMode;
1703+
bool isWidescreen;
1704+
};
1705+
16961706
//
16971707
// PopulateResolutionComboBox
16981708
//
@@ -1706,47 +1716,86 @@ void CSettings::PopulateResolutionComboBox()
17061716
bool bShowUnsafeResolutions = m_pCheckBoxShowUnsafeResolutions->GetSelected();
17071717

17081718
CGameSettings* gameSettings = CCore::GetSingleton().GetGame()->GetSettings();
1719+
if (!gameSettings)
1720+
return;
17091721

17101722
VideoMode vidModemInfo;
17111723
int vidMode, numVidModes;
1724+
std::vector<ResolutionData> resolutions;
17121725

1726+
if (!m_pComboResolution)
1727+
return;
1728+
17131729
m_pComboResolution->Clear();
17141730
numVidModes = gameSettings->GetNumVideoModes();
17151731

17161732
for (vidMode = 0; vidMode < numVidModes; vidMode++)
17171733
{
1718-
gameSettings->GetVideoModeInfo(&vidModemInfo, vidMode);
1734+
if (!gameSettings->GetVideoModeInfo(&vidModemInfo, vidMode))
1735+
continue;
17191736

17201737
// Remove resolutions that will make the gui unusable
17211738
if (vidModemInfo.width < 640 || vidModemInfo.height < 480)
17221739
continue;
17231740

1741+
// Check resolution is below desktop res unless that is allowed
1742+
if (gameSettings->IsUnsafeResolution(vidModemInfo.width, vidModemInfo.height) && !bShowUnsafeResolutions)
1743+
continue;
1744+
1745+
if (!(vidModemInfo.flags & rwVIDEOMODEEXCLUSIVE))
1746+
continue;
1747+
1748+
ResolutionData resData;
1749+
resData.width = vidModemInfo.width;
1750+
resData.height = vidModemInfo.height;
1751+
resData.depth = vidModemInfo.depth;
1752+
resData.vidMode = vidMode;
1753+
resData.isWidescreen = (vidModemInfo.flags & rwVIDEOMODE_XBOX_WIDESCREEN) != 0;
1754+
17241755
// Check resolution hasn't already been added
17251756
bool bDuplicate = false;
1726-
for (int i = 1; i < vidMode; i++)
1757+
for (const auto& existing : resolutions)
17271758
{
1728-
VideoMode info;
1729-
gameSettings->GetVideoModeInfo(&info, i);
1730-
if (info.width == vidModemInfo.width && info.height == vidModemInfo.height && info.depth == vidModemInfo.depth)
1759+
if (existing.width == resData.width && existing.height == resData.height && existing.depth == resData.depth)
1760+
{
17311761
bDuplicate = true;
1762+
break;
1763+
}
17321764
}
1733-
if (bDuplicate)
1734-
continue;
1735-
1736-
// Check resolution is below desktop res unless that is allowed
1737-
if (gameSettings->IsUnsafeResolution(vidModemInfo.width, vidModemInfo.height) && !bShowUnsafeResolutions)
1738-
continue;
1765+
1766+
if (!bDuplicate)
1767+
resolutions.push_back(resData);
1768+
}
17391769

1740-
SString strMode("%lu x %lu x %lu", vidModemInfo.width, vidModemInfo.height, vidModemInfo.depth);
1770+
if (resolutions.empty())
1771+
return;
17411772

1742-
if (vidModemInfo.flags & rwVIDEOMODEEXCLUSIVE)
1743-
m_pComboResolution->AddItem(strMode)->SetData((void*)vidMode);
1773+
// Sort resolutions by width (descending), then by height, then by depth
1774+
std::sort(resolutions.begin(), resolutions.end(), [](const ResolutionData& a, const ResolutionData& b) {
1775+
if (a.width != b.width)
1776+
return a.width > b.width;
1777+
if (a.height != b.height)
1778+
return a.height > b.height;
1779+
return a.depth > b.depth;
1780+
});
1781+
1782+
SString selectedText;
1783+
VideoMode currentInfo;
1784+
if (gameSettings->GetVideoModeInfo(&currentInfo, iNextVidMode))
1785+
{
1786+
for (const auto& res : resolutions)
1787+
{
1788+
SString strMode("%d x %d x %d", res.width, res.height, res.depth);
1789+
CGUIListItem* pItem = m_pComboResolution->AddItem(strMode);
1790+
if (pItem)
1791+
pItem->SetData((void*)res.vidMode);
17441792

1745-
VideoMode currentInfo;
1746-
gameSettings->GetVideoModeInfo(&currentInfo, iNextVidMode);
1793+
if (currentInfo.width == res.width && currentInfo.height == res.height && currentInfo.depth == res.depth)
1794+
selectedText = strMode;
1795+
}
17471796

1748-
if (currentInfo.width == vidModemInfo.width && currentInfo.height == vidModemInfo.height && currentInfo.depth == vidModemInfo.depth)
1749-
m_pComboResolution->SetText(strMode);
1797+
if (!selectedText.empty())
1798+
m_pComboResolution->SetText(selectedText);
17501799
}
17511800
}
17521801

Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,8 +1773,6 @@ int CLuaDrawingDefs::DxGetStatus(lua_State* luaVM)
17731773
return "#0000 Resize always";
17741774
case EDiagnosticDebug::RESIZE_NEVER_0000:
17751775
return "#0000 Resize never";
1776-
case EDiagnosticDebug::BAD_ALLOC:
1777-
return "#0000 Memory allocation debug";
17781776
default:
17791777
return "Default";
17801778
}

0 commit comments

Comments
 (0)