Merge pull request #109 from MindRapist/mr-14

Fog fixes
This commit is contained in:
rtw1x1
2026-02-16 17:55:36 +00:00
committed by GitHub
9 changed files with 124 additions and 22 deletions

View File

@@ -16,10 +16,7 @@ This repository contains the source code necessary to compile the game client ex
## 📋 Changelog ## 📋 Changelog
### 🐛 Bug fixes ### 🐛 Bug fixes
- **TempTrace**: Added `n` support for Python - **Fog update**: Adjusted fog settings to work with the updated official version using the 3 classic options.
- **Togglable slots**: Fixed slots not deactivating on death
- **Affects**: Added affect shower support for Mall Attack Speed
- **Specular**: Fixed a bug where specular would not isolate to the targeted item. Swapping for example to a weapon with different specular would cause all surrounding weapon meshes to change specular as well. The issue has been fixed.
<br> <br>
<br> <br>

View File

@@ -241,7 +241,9 @@ void CStateManager::SetDefaultState()
SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
SetRenderState(D3DRS_FOGENABLE, FALSE); SetRenderState(D3DRS_FOGENABLE, FALSE);
SetRenderState(D3DRS_FOGCOLOR, 0xFF000000); SetRenderState(D3DRS_FOGCOLOR, 0xFF000000);
SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR); // MR-14: Fog update by Alaric
SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_NONE);
// MR-14: -- END OF -- Fog update by Alaric
SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR); SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
SetRenderState(D3DRS_RANGEFOGENABLE, FALSE); SetRenderState(D3DRS_RANGEFOGENABLE, FALSE);
SetRenderState(D3DRS_ZENABLE, TRUE); SetRenderState(D3DRS_ZENABLE, TRUE);

View File

@@ -7,6 +7,19 @@
#include "PropertyLoader.h" #include "PropertyLoader.h"
// MR-14: Fog update by Alaric
// Not the proper way to handle this but I'm lazy
#ifdef _DEBUG
#undef _DEBUG
#include <python/python.h>
#define _DEBUG
#else
#include <python/python.h>
#endif
#include "UserInterface/PythonSystem.h"
// MR-14: -- END OF -- Fog update by Alaric
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// 기본 함수 // 기본 함수
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -251,12 +264,30 @@ void CMapManager::BeginEnvironment()
DWORD dwFogColor = mc_pcurEnvironmentData->FogColor; DWORD dwFogColor = mc_pcurEnvironmentData->FogColor;
STATEMANAGER.SetRenderState(D3DRS_FOGCOLOR, dwFogColor); STATEMANAGER.SetRenderState(D3DRS_FOGCOLOR, dwFogColor);
if (mc_pcurEnvironmentData->bDensityFog) // MR-14: Fog update by Alaric
// DIFFERENCE WITH THE OFFICIAL VERSION:
/*
Currently the official does not use the buttons "Dense", "Middle", "Light" for fog density. Instead,
they use an On/Off boolean variable. To maintain the classic feel in the settings, we customized the
modern official functionality into the 3-way button controls.
To migrate to boolean (official-like), replace mc_pcurEnvironmentData->bDensityFog with m_isFogModeEnabled
and remove the const float fFogDensityLevel[3] and instead, multiple mc_pcurEnvironmentData->bFogLevel with
the official 0.000010f value for the fDensity.
To migrate with the official, other variables in this update must be adjusted as well.
*/
if (mc_pcurEnvironmentData->bDensityFog && mc_pcurEnvironmentData->bFogLevel != 0)
{ {
float fDensity = 0.00015f; const float fFogDensityLevel[3] = { 0.000020f, 0.000010f, 0.000005f };
float fDensity = mc_pcurEnvironmentData->bFogLevel * fFogDensityLevel[CPythonSystem::Instance().GetFogLevel()];
STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP); // pixel fog STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP); // pixel fog
STATEMANAGER.SetRenderState(D3DRS_FOGDENSITY, *((DWORD *) &fDensity)); // vertex fog STATEMANAGER.SetRenderState(D3DRS_FOGDENSITY, *((DWORD *) &fDensity)); // vertex fog
} }
// MR-14: -- END OF -- Fog update by Alaric
else else
{ {
CSpeedTreeForestDirectX8& rkForest=CSpeedTreeForestDirectX8::Instance(); CSpeedTreeForestDirectX8& rkForest=CSpeedTreeForestDirectX8::Instance();
@@ -267,6 +298,7 @@ void CMapManager::BeginEnvironment()
float fFogNear=mc_pcurEnvironmentData->GetFogNearDistance(); float fFogNear=mc_pcurEnvironmentData->GetFogNearDistance();
float fFogFar=mc_pcurEnvironmentData->GetFogFarDistance(); float fFogFar=mc_pcurEnvironmentData->GetFogFarDistance();
STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR); // vertex fox STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR); // vertex fox
STATEMANAGER.SetRenderState(D3DRS_RANGEFOGENABLE, TRUE); // vertex fox STATEMANAGER.SetRenderState(D3DRS_RANGEFOGENABLE, TRUE); // vertex fox
STATEMANAGER.SetRenderState(D3DRS_FOGSTART, *((DWORD *) &fFogNear)); // USED BY D3DFOG_LINEAR STATEMANAGER.SetRenderState(D3DRS_FOGSTART, *((DWORD *) &fFogNear)); // USED BY D3DFOG_LINEAR

View File

@@ -89,11 +89,15 @@ void CMapOutdoor::__RenderTerrain_RenderHardwareTransformPatch()
SelectIndexBuffer(0, &wPrimitiveCount, &ePrimitiveType); SelectIndexBuffer(0, &wPrimitiveCount, &ePrimitiveType);
DWORD dwFogEnable = STATEMANAGER.GetRenderState(D3DRS_FOGENABLE); // MR-14: Fog update by Alaric
// DWORD dwFogEnable = STATEMANAGER.GetRenderState(D3DRS_FOGENABLE);
// MR-14: -- END OF -- Fog update by Alaric
std::vector<std::pair<float, long> >::iterator it = m_PatchVector.begin(); std::vector<std::pair<float, long> >::iterator it = m_PatchVector.begin();
// NOTE: 맵툴에서는 view ~ fog near 사이의 지형을 fog disabled 상태로 그리는 작업을 하지 않음. // NOTE: 맵툴에서는 view ~ fog near 사이의 지형을 fog disabled 상태로 그리는 작업을 하지 않음.
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE); // MR-14: Fog update by Alaric
// STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
// MR-14: -- END OF -- Fog update by Alaric
for(; it != near_it; ++it) for(; it != near_it; ++it)
{ {
@@ -109,6 +113,7 @@ void CMapOutdoor::__RenderTerrain_RenderHardwareTransformPatch()
} }
__HardwareTransformPatch_RenderPatchSplat(it->second, wPrimitiveCount, ePrimitiveType); __HardwareTransformPatch_RenderPatchSplat(it->second, wPrimitiveCount, ePrimitiveType);
if (m_iRenderedSplatNum >= m_iSplatLimit) if (m_iRenderedSplatNum >= m_iSplatLimit)
break; break;
@@ -116,7 +121,9 @@ void CMapOutdoor::__RenderTerrain_RenderHardwareTransformPatch()
DrawWireFrame(it->second, wPrimitiveCount, ePrimitiveType); DrawWireFrame(it->second, wPrimitiveCount, ePrimitiveType);
} }
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, dwFogEnable); // MR-14: Fog update by Alaric
// STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, dwFogEnable);
// MR-14: -- END OF -- Fog update by Alaric
if (m_iRenderedSplatNum < m_iSplatLimit) if (m_iRenderedSplatNum < m_iSplatLimit)
{ {
@@ -143,7 +150,9 @@ void CMapOutdoor::__RenderTerrain_RenderHardwareTransformPatch()
} }
} }
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE); // MR-14: Fog update by Alaric
// STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
// MR-14: -- END OF -- Fog update by Alaric
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE); STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
STATEMANAGER.SetTexture(0, NULL); STATEMANAGER.SetTexture(0, NULL);
@@ -195,7 +204,9 @@ void CMapOutdoor::__RenderTerrain_RenderHardwareTransformPatch()
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, dwFogEnable); // MR-14: Fog update by Alaric
// STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, dwFogEnable);
// MR-14: -- END OF -- Fog update by Alaric
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE); STATEMANAGER.SetRenderState(D3DRS_LIGHTING, TRUE);
std::sort(m_RenderedTextureNumVector.begin(),m_RenderedTextureNumVector.end()); std::sort(m_RenderedTextureNumVector.begin(),m_RenderedTextureNumVector.end());

View File

@@ -143,6 +143,9 @@ typedef struct SEnvironmentData
float GetFogFarDistance() const; float GetFogFarDistance() const;
D3DXCOLOR FogColor; D3DXCOLOR FogColor;
// MR-14: Fog update by Alaric
BYTE bFogLevel;
// MR-14: -- END OF -- Fog update by Alaric
// Filtering // Filtering
BOOL bFilteringEnable; BOOL bFilteringEnable;

View File

@@ -27,8 +27,10 @@ void Environment_Init(SEnvironmentData& envData)
envData.Material.Specular = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); envData.Material.Specular = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f);
envData.Material.Power = 0.0f; envData.Material.Power = 0.0f;
envData.bFogEnable = FALSE; // MR-14: Fog update by Alaric
envData.bDensityFog = FALSE; envData.bFogEnable = TRUE;
envData.bDensityFog = TRUE;
// MR-14: -- END OF -- Fog update by Alaric
envData.m_fFogNearDistance = 25600.0f * 0.5f; envData.m_fFogNearDistance = 25600.0f * 0.5f;
envData.m_fFogFarDistance = 25600.0f * 0.7f; envData.m_fFogFarDistance = 25600.0f * 0.7f;
envData.FogColor = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f); envData.FogColor = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
@@ -114,10 +116,13 @@ bool Environment_Load(SEnvironmentData& envData, const char* envFileName)
if (textLoader.SetChildNode("fog")) if (textLoader.SetChildNode("fog"))
{ {
textLoader.GetTokenBoolean("enable", &envData.bFogEnable); // MR-14: Fog update by Alaric
textLoader.GetTokenBoolean("isdensity", &envData.bDensityFog); // textLoader.GetTokenBoolean("enable", &envData.bFogEnable);
textLoader.GetTokenFloat("neardistance", &envData.m_fFogNearDistance); // textLoader.GetTokenBoolean("isdensity", &envData.bDensityFog);
textLoader.GetTokenFloat("fardistance", &envData.m_fFogFarDistance); // textLoader.GetTokenFloat("neardistance", &envData.m_fFogNearDistance);
// textLoader.GetTokenFloat("fardistance", &envData.m_fFogFarDistance);
textLoader.GetTokenByte("foglevel", &envData.bFogLevel);
// MR-14: -- END OF -- Fog update by Alaric
textLoader.GetTokenColor("color", &envData.FogColor); textLoader.GetTokenColor("color", &envData.FogColor);
textLoader.SetParentNode(); textLoader.SetParentNode();
} }

View File

@@ -244,6 +244,18 @@ void CPythonSystem::SetShadowLevel(unsigned int level)
CPythonBackground::instance().RefreshShadowLevel(); CPythonBackground::instance().RefreshShadowLevel();
} }
// MR-14: Fog update by Alaric
int CPythonSystem::GetFogLevel()
{
return m_Config.iFogLevel;
}
void CPythonSystem::SetFogLevel(unsigned int level)
{
m_Config.iFogLevel = MIN(level, 2);
}
// MR-14: -- END OF -- Fog update by Alaric
int CPythonSystem::IsSaveID() int CPythonSystem::IsSaveID()
{ {
return m_Config.isSaveID; return m_Config.isSaveID;
@@ -299,6 +311,9 @@ void CPythonSystem::SetDefaultConfig()
m_Config.bDecompressDDS = 0; m_Config.bDecompressDDS = 0;
m_Config.bSoftwareTiling = 0; m_Config.bSoftwareTiling = 0;
m_Config.iShadowLevel = 3; m_Config.iShadowLevel = 3;
// MR-14: Fog update by Alaric
m_Config.iFogLevel = 0;
// MR-14: -- END OF -- Fog update by Alaric
m_Config.bViewChat = true; m_Config.bViewChat = true;
m_Config.bAlwaysShowName = DEFAULT_VALUE_ALWAYS_SHOW_NAME; m_Config.bAlwaysShowName = DEFAULT_VALUE_ALWAYS_SHOW_NAME;
m_Config.bShowDamage = true; m_Config.bShowDamage = true;
@@ -431,6 +446,10 @@ bool CPythonSystem::LoadConfig()
m_Config.bSoftwareTiling = atoi(value); m_Config.bSoftwareTiling = atoi(value);
else if (!stricmp(command, "SHADOW_LEVEL")) else if (!stricmp(command, "SHADOW_LEVEL"))
m_Config.iShadowLevel = atoi(value); m_Config.iShadowLevel = atoi(value);
// MR-14: Fog update by Alaric
else if (!stricmp(command, "FOG_LEVEL"))
m_Config.iFogLevel = atoi(value);
// MR-14: -- END OF -- Fog update by Alaric
else if (!stricmp(command, "DECOMPRESSED_TEXTURE")) else if (!stricmp(command, "DECOMPRESSED_TEXTURE"))
m_Config.bDecompressDDS = atoi(value) == 1 ? true : false; m_Config.bDecompressDDS = atoi(value) == 1 ? true : false;
else if (!stricmp(command, "NO_SOUND_CARD")) else if (!stricmp(command, "NO_SOUND_CARD"))
@@ -533,6 +552,9 @@ bool CPythonSystem::SaveConfig()
fprintf(fp, "USE_DEFAULT_IME %d\n", m_Config.bUseDefaultIME); fprintf(fp, "USE_DEFAULT_IME %d\n", m_Config.bUseDefaultIME);
fprintf(fp, "SOFTWARE_TILING %d\n", m_Config.bSoftwareTiling); fprintf(fp, "SOFTWARE_TILING %d\n", m_Config.bSoftwareTiling);
fprintf(fp, "SHADOW_LEVEL %d\n", m_Config.iShadowLevel); fprintf(fp, "SHADOW_LEVEL %d\n", m_Config.iShadowLevel);
// MR-14: Fog update by Alaric
fprintf(fp, "FOG_LEVEL %d\n", m_Config.iFogLevel);
// MR-14: -- END OF -- Fog update by Alaric
fprintf(fp, "\n"); fprintf(fp, "\n");
fclose(fp); fclose(fp);

View File

@@ -57,6 +57,9 @@ class CPythonSystem : public CSingleton<CPythonSystem>
bool is_object_culling; bool is_object_culling;
int iDistance; int iDistance;
int iShadowLevel; int iShadowLevel;
// MR-14: Fog update by Alaric
int iFogLevel;
// MR-14: -- END OF -- Fog update by Alaric
FLOAT music_volume; FLOAT music_volume;
FLOAT voice_volume; FLOAT voice_volume;
@@ -149,6 +152,11 @@ class CPythonSystem : public CSingleton<CPythonSystem>
int GetShadowLevel(); int GetShadowLevel();
void SetShadowLevel(unsigned int level); void SetShadowLevel(unsigned int level);
// MR-14: Fog update by Alaric
int GetFogLevel();
void SetFogLevel(unsigned int level);
// MR-14: -- END OF -- Fog update by Alaric
protected: protected:
TResolution m_ResolutionList[RESOLUTION_MAX_NUM]; TResolution m_ResolutionList[RESOLUTION_MAX_NUM];
int m_ResolutionCount; int m_ResolutionCount;

View File

@@ -372,10 +372,32 @@ PyObject * systemSetShadowLevel(PyObject * poSelf, PyObject * poArgs)
return Py_BuildNone(); return Py_BuildNone();
} }
// MR-14: Fog update by Alaric
PyObject * systemGetFogLevel(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonSystem::Instance().GetFogLevel());
}
PyObject * systemSetFogLevel(PyObject * poSelf, PyObject * poArgs)
{
int iLevel;
if (!PyTuple_GetInteger(poArgs, 0, &iLevel))
return Py_BuildException();
CPythonSystem::Instance().SetFogLevel(iLevel);
return Py_BuildNone();
}
// MR-14: -- END OF -- Fog update by Alaric
void initsystem() void initsystem()
{ {
static PyMethodDef s_methods[] = static PyMethodDef s_methods[] =
{ {
// MR-14: Fog update by Alaric
{ "GetFogLevel", systemGetFogLevel, METH_VARARGS },
{ "SetFogLevel", systemSetFogLevel, METH_VARARGS },
// MR-14: -- END OF -- Fog update by Alaric
{ "GetWidth", systemGetWidth, METH_VARARGS }, { "GetWidth", systemGetWidth, METH_VARARGS },
{ "GetHeight", systemGetHeight, METH_VARARGS }, { "GetHeight", systemGetHeight, METH_VARARGS },