Skip to content

Commit 557b78f

Browse files
authored
Merge branch 'master' into feature/additional-weapon-customization
2 parents b51a7a0 + 7f23f61 commit 557b78f

100 files changed

Lines changed: 799 additions & 443 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Client/core/CConsole.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bool CConsole::IsEnabled()
123123

124124
void CConsole::SetEnabled(bool bEnabled)
125125
{
126-
// Hide it if neccessary
126+
// Hide it if necessary
127127
if (!bEnabled && m_pWindow->IsVisible())
128128
{
129129
SetVisible(false);

Client/core/CGUI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ bool CLocalGUI::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara
745745
return true;
746746
case WM_IME_KEYDOWN:
747747
{
748-
// Handle space/return seperately in this case
748+
// Handle space/return separately in this case
749749
if (wParam == VK_SPACE)
750750
pGUI->ProcessCharacter(MapVirtualKey(wParam, MAPVK_VK_TO_CHAR));
751751

Client/core/CScreenShot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static bool ms_bBeforeGUI = false;
2626

2727
static SString ms_strScreenDirectoryPath;
2828

29-
// Last save time, seperated per given type
29+
// Last save time, separated per given type
3030
// (normal screenshot or camera weapon initiated)
3131
static long long ms_lLastSaveTime[2] = {0, 0};
3232

Client/core/CTrayIcon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool CTrayIcon::CreateTrayIcon()
6969
return false;
7070
}
7171

72-
// The handle to the core.dll is neccessary here,
72+
// The handle to the core.dll is necessary here,
7373
// because Windows will search for the ICON in the executable and not in the DLL
7474
// Note: Changing the size will not show a higher quality icon in the balloon
7575
auto hIcon = LoadImage(g_hModule, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, LR_DEFAULTSIZE, LR_DEFAULTSIZE, LR_SHARED | LR_LOADTRANSPARENT);

Client/core/DXHook/CDirect3DHookManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: Client/core/DXHook/CDirect3DHookManager.cpp
6-
* PURPOSE: Direct3D version independant hook manager
6+
* PURPOSE: Direct3D version independent hook manager
77
*
88
* Multi Theft Auto is available from https://multitheftauto.com/
99
*

Client/core/DXHook/CProxyDirect3D9.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ namespace
11941194
//
11951195
// Hook CCore::OnPreCreateDevice
11961196
//
1197-
// Modify paramters
1197+
// Modify parameters
11981198
//
11991199
////////////////////////////////////////////////
12001200
void CCore::OnPreCreateDevice(IDirect3D9* pDirect3D, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD& BehaviorFlags,
@@ -1224,7 +1224,7 @@ void CCore::OnPreCreateDevice(IDirect3D9* pDirect3D, UINT Adapter, D3DDEVTYPE De
12241224
BehaviorFlagsOrig = BehaviorFlags;
12251225
presentationParametersOrig = *pPresentationParameters;
12261226

1227-
WriteDebugEvent(" Original paramters:");
1227+
WriteDebugEvent(" Original parameters:");
12281228
WriteDebugEvent(ToString(Adapter, DeviceType, hFocusWindow, BehaviorFlags, *pPresentationParameters));
12291229

12301230
// Make sure DirectX Get...() calls will work
@@ -1235,7 +1235,7 @@ void CCore::OnPreCreateDevice(IDirect3D9* pDirect3D, UINT Adapter, D3DDEVTYPE De
12351235

12361236
GetVideoModeManager()->PreCreateDevice(pPresentationParameters);
12371237

1238-
WriteDebugEvent(" Modified paramters:");
1238+
WriteDebugEvent(" Modified parameters:");
12391239
WriteDebugEvent(ToString(Adapter, DeviceType, hFocusWindow, BehaviorFlags, *pPresentationParameters));
12401240
}
12411241

@@ -1309,7 +1309,7 @@ HRESULT CCore::OnPostCreateDevice(HRESULT hResult, IDirect3D9* pDirect3D, UINT A
13091309
BehaviorFlagsOrig = BehaviorFlags;
13101310
presentationParametersOrig = *pPresentationParameters;
13111311

1312-
WriteDebugEvent(" Original paramters:");
1312+
WriteDebugEvent(" Original parameters:");
13131313
WriteDebugEvent(ToString(Adapter, DeviceType, hFocusWindow, BehaviorFlags, *pPresentationParameters));
13141314

13151315
// Make sure DirectX Get...() calls will work
@@ -1320,7 +1320,7 @@ HRESULT CCore::OnPostCreateDevice(HRESULT hResult, IDirect3D9* pDirect3D, UINT A
13201320

13211321
GetVideoModeManager()->PreCreateDevice(pPresentationParameters);
13221322

1323-
WriteDebugEvent(" Modified paramters:");
1323+
WriteDebugEvent(" Modified parameters:");
13241324
WriteDebugEvent(ToString(Adapter, DeviceType, hFocusWindow, BehaviorFlags, *pPresentationParameters));
13251325

13261326
hResult = CreateDeviceInsist(2, 1000, pDirect3D, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);

Client/core/DXHook/CProxyDirect3DEffect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ HRESULT CProxyDirect3DEffect::CloneEffect(LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFEC
173173
//
174174
// MyD3DXCreateEffectFromFile
175175
//
176-
// Wrap result of orignal function
176+
// Wrap result of original function
177177
//
178178
/////////////////////////////////////////////////////////////
179179
HRESULT WINAPI MyD3DXCreateEffectFromFile(LPDIRECT3DDEVICE9 pDevice, LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags,
@@ -192,7 +192,7 @@ HRESULT WINAPI MyD3DXCreateEffectFromFile(LPDIRECT3DDEVICE9 pDevice, LPCSTR pSrc
192192
//
193193
// D3DXCreateEffect
194194
//
195-
// Wrap result of orignal function
195+
// Wrap result of original function
196196
//
197197
/////////////////////////////////////////////////////////////
198198
HRESULT WINAPI MyD3DXCreateEffect(LPDIRECT3DDEVICE9 pDevice, LPCVOID pSrcData, UINT SrcDataLen, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, DWORD Flags,

Client/core/DXHook/CProxyDirectInput8.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CProxyDirectInput8::CProxyDirectInput8(IDirectInput8* pDevice)
1515
{
1616
WriteDebugEvent(SString("CProxyDirectInput8::CProxyDirectInput8 %08x", this));
1717

18-
// Initalize our local variable.
18+
// Initialize our local variable.
1919
m_pDevice = pDevice;
2020
}
2121

Client/core/Graphics/CGraphics.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,40 @@ extern std::atomic<bool> g_bInMTAScene;
2727

2828
using namespace std;
2929

30+
namespace
31+
{
32+
// Convert a straight-alpha ARGB tint into its premultiplied form:
33+
//
34+
// (R, G, B, A) -> (R*A/255, G*A/255, B*A/255, A)
35+
//
36+
// Needed when routing a translucent draw onto the (ONE, INVSRCALPHA)
37+
// pipeline. That pipeline computes
38+
//
39+
// out.rgb = src.rgb + dst.rgb * (1 - src.a)
40+
//
41+
// with src.rgb = tex.rgb * diff.rgb and src.a = tex.a * diff.a, so
42+
// diff.a never enters the source rgb term. For a PM texel tex.rgb =
43+
// R*A_tex, that leaves
44+
//
45+
// out.rgb = R * A_tex * diff.rgb + dst.rgb * (1 - A_tex * diff.a)
46+
//
47+
// which is brighter than the correct PM composite by a factor of
48+
// 1/diff.a during a fade. Premultiplying the diffuse here
49+
// (diff.rgb *= diff.a) restores the missing factor and the equation
50+
// reduces exactly to the PM "over" operator.
51+
inline SColor PremultiplyAlpha(SColor c) noexcept
52+
{
53+
if (c.A == 0xFF)
54+
return c;
55+
56+
const uint a = c.A;
57+
c.R = static_cast<unsigned char>((c.R * a + 127) / 255);
58+
c.G = static_cast<unsigned char>((c.G * a + 127) / 255);
59+
c.B = static_cast<unsigned char>((c.B * a + 127) / 255);
60+
return c;
61+
}
62+
} // namespace
63+
3064
template <>
3165
CGraphics* CSingleton<CGraphics>::m_pSingleton = NULL;
3266

@@ -1080,6 +1114,15 @@ void CGraphics::DrawMaterialPrimitiveQueued(std::vector<PrimitiveMaterialVertice
10801114
sDrawQueueItem Item;
10811115
Item.eType = QUEUE_PRIMITIVEMATERIAL;
10821116
Item.blendMode = m_ActiveBlendMode;
1117+
// Same PM auto-route as DrawTextureQueued, so dxDrawMaterialPrimitive
1118+
// composites SVG (premultiplied) textures correctly under default blend.
1119+
if (Item.blendMode == EBlendMode::BLEND && pMaterial && pMaterial->m_bPremultipliedAlpha)
1120+
{
1121+
Item.blendMode = EBlendMode::ADD;
1122+
// See PremultiplyAlpha for the diffuse premultiply rationale (#3828).
1123+
for (auto& vert : *pVecVertices)
1124+
vert.Color = PremultiplyAlpha(vert.Color);
1125+
}
10831126
Item.PrimitiveMaterial.eType = eType;
10841127
Item.PrimitiveMaterial.pMaterial = pMaterial;
10851128
Item.PrimitiveMaterial.pVecVertices = pVecVertices;
@@ -1134,6 +1177,16 @@ void CGraphics::DrawTextureQueued(float fX, float fY, float fWidth, float fHeigh
11341177
// Set up a queue item
11351178
sDrawQueueItem Item;
11361179
Item.blendMode = m_ActiveBlendMode;
1180+
// Premultiplied-alpha textures (SVG) need the (ONE, INVSRCALPHA) pipeline,
1181+
// not the straight-alpha BLEND mode. Route the default blend to ADD when
1182+
// the script hasn't asked for a specific mode (issue #4891), and convert
1183+
// the diffuse tint to PM so a translucent dxDrawImage call still fades
1184+
// correctly through that pipeline (issue #3828).
1185+
if (Item.blendMode == EBlendMode::BLEND && pMaterial && pMaterial->m_bPremultipliedAlpha)
1186+
{
1187+
Item.blendMode = EBlendMode::ADD;
1188+
ulColor = PremultiplyAlpha(ulColor);
1189+
}
11371190
Item.Texture.fX = fX;
11381191
Item.Texture.fY = fY;
11391192
Item.Texture.fWidth = fWidth;

Client/core/Graphics/CMaterialLine3DBatcher.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void CMaterialLine3DBatcher::Flush()
128128
std::vector<uint> indexList;
129129
indexList.resize(uiNumLines);
130130
uint* pIndices = &indexList[0];
131-
uint uiNumIndicies = 0;
131+
uint uiNumIndices = 0;
132132

133133
// Calculate distances
134134
for (uint i = 0; i < uiNumLines; i++)
@@ -149,12 +149,12 @@ void CMaterialLine3DBatcher::Flush()
149149
continue;
150150
}
151151
// Add the index for this line to the draw list
152-
pIndices[uiNumIndicies++] = i;
152+
pIndices[uiNumIndices++] = i;
153153
}
154154

155-
if (uiNumIndicies > 0)
155+
if (uiNumIndices > 0)
156156
{
157-
indexList.resize(uiNumIndicies);
157+
indexList.resize(uiNumIndices);
158158

159159
// Sort index list by distance
160160
ms_pLines = &m_LineList[0];
@@ -164,12 +164,12 @@ void CMaterialLine3DBatcher::Flush()
164164

165165
// Draw index list, batching by material
166166
uint uiBatchFirstIndex = 0;
167-
for (uint i = 0; i < uiNumIndicies; i++)
167+
for (uint i = 0; i < uiNumIndices; i++)
168168
{
169169
const SMaterialLine3DItem& item = ms_pLines[pIndices[i]];
170170

171171
// Flush batch if this is the last index, or the next one uses a different material
172-
if ((i == uiNumIndicies - 1) || item.pMaterial != ms_pLines[pIndices[i + 1]].pMaterial)
172+
if ((i == uiNumIndices - 1) || item.pMaterial != ms_pLines[pIndices[i + 1]].pMaterial)
173173
{
174174
uint* pBatchIndices = &pIndices[uiBatchFirstIndex];
175175
uint uiNumBatchLines = i - uiBatchFirstIndex + 1;

0 commit comments

Comments
 (0)