Skip to content

Commit 068e26b

Browse files
committed
Add high-performance, carefully engineered allocator (Addendum to 5dc09d9)
1 parent c9aa55c commit 068e26b

File tree

7 files changed

+1276
-333
lines changed

7 files changed

+1276
-333
lines changed

Client/core/CSettings.cpp

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

1212
#include "StdInc.h"
13-
#include <algorithm>
14-
#include <vector>
1513
#include <core/CClientCommands.h>
1614
#include <game/CGame.h>
1715
#include <game/CSettings.h>
@@ -1149,6 +1147,7 @@ void CSettings::CreateGUI()
11491147
m_pDebugSettingCombo->AddItem("#0000 Lua trace")->SetData((void*)EDiagnosticDebug::LUA_TRACE_0000);
11501148
m_pDebugSettingCombo->AddItem("#0000 Resize always")->SetData((void*)EDiagnosticDebug::RESIZE_ALWAYS_0000);
11511149
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);
11521151
m_pDebugSettingCombo->SetReadOnly(true);
11531152
vecTemp.fY += fLineHeight;
11541153

@@ -1694,15 +1693,6 @@ void CSettings::UpdateVideoTab()
16941693
m_pPlayerMapImageCombo->SetSelectedItemByIndex(iVar);
16951694
}
16961695

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

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

17221710
VideoMode vidModemInfo;
17231711
int vidMode, numVidModes;
1724-
std::vector<ResolutionData> resolutions;
17251712

1726-
if (!m_pComboResolution)
1727-
return;
1728-
17291713
m_pComboResolution->Clear();
17301714
numVidModes = gameSettings->GetNumVideoModes();
17311715

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

17371720
// Remove resolutions that will make the gui unusable
17381721
if (vidModemInfo.width < 640 || vidModemInfo.height < 480)
17391722
continue;
17401723

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-
17551724
// Check resolution hasn't already been added
17561725
bool bDuplicate = false;
1757-
for (const auto& existing : resolutions)
1726+
for (int i = 1; i < vidMode; i++)
17581727
{
1759-
if (existing.width == resData.width && existing.height == resData.height && existing.depth == resData.depth)
1760-
{
1728+
VideoMode info;
1729+
gameSettings->GetVideoModeInfo(&info, i);
1730+
if (info.width == vidModemInfo.width && info.height == vidModemInfo.height && info.depth == vidModemInfo.depth)
17611731
bDuplicate = true;
1762-
break;
1763-
}
17641732
}
1765-
1766-
if (!bDuplicate)
1767-
resolutions.push_back(resData);
1768-
}
1733+
if (bDuplicate)
1734+
continue;
17691735

1770-
if (resolutions.empty())
1771-
return;
1736+
// Check resolution is below desktop res unless that is allowed
1737+
if (gameSettings->IsUnsafeResolution(vidModemInfo.width, vidModemInfo.height) && !bShowUnsafeResolutions)
1738+
continue;
17721739

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);
1740+
SString strMode("%lu x %lu x %lu", vidModemInfo.width, vidModemInfo.height, vidModemInfo.depth);
17921741

1793-
if (currentInfo.width == res.width && currentInfo.height == res.height && currentInfo.depth == res.depth)
1794-
selectedText = strMode;
1795-
}
1742+
if (vidModemInfo.flags & rwVIDEOMODEEXCLUSIVE)
1743+
m_pComboResolution->AddItem(strMode)->SetData((void*)vidMode);
1744+
1745+
VideoMode currentInfo;
1746+
gameSettings->GetVideoModeInfo(&currentInfo, iNextVidMode);
17961747

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,8 @@ 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";
17761778
default:
17771779
return "Default";
17781780
}

0 commit comments

Comments
 (0)