Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit afe7ea3

Browse files
committed
Some settling/piling logic fixes
(cherry picked from commit 9509d1c)
1 parent 537904f commit afe7ea3

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

Managers/MovableMan.cpp

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,34 +1945,30 @@ void MovableMan::Update()
19451945

19461946
// SETTLE PARTICLES //////////////////////////////////////////////////
19471947
// Only settle after all updates and deletions are done
1948-
if (m_SettlingEnabled)
1949-
{
1950-
parIt = partition(m_Particles.begin(), m_Particles.end(), std::not_fn(std::mem_fn(&MovableObject::ToSettle)));
1951-
midIt = parIt;
1952-
1953-
while (parIt != m_Particles.end())
1954-
{
1955-
Vector parPos((*parIt)->GetPos().GetFloored());
1956-
Material const * terrMat = g_SceneMan.GetMaterialFromID(g_SceneMan.GetTerrain()->GetMaterialPixel(parPos.m_X, parPos.m_Y));
1957-
if ((*parIt)->GetDrawPriority() >= terrMat->GetPriority()) {
1958-
int piling = (*parIt)->GetMaterial()->GetPiling();
1959-
if (piling >= 0) {
1960-
for (int s = 0; terrMat->GetIndex() == (*parIt)->GetMaterial()->GetIndex() && s < piling; ++s) {
1961-
if (s % 2 == 0) {
1962-
parPos.m_Y -= 1.0F;
1963-
} else {
1964-
parPos.m_X += (RandomNum() >= 0.5F ? 1.0F : -1.0F);
1965-
}
1966-
terrMat = g_SceneMan.GetMaterialFromID(g_SceneMan.GetTerrain()->GetMaterialPixel(parPos.m_X, parPos.m_Y));
1948+
if (m_SettlingEnabled) {
1949+
parIt = partition(m_Particles.begin(), m_Particles.end(), std::not_fn(std::mem_fn(&MovableObject::ToSettle)));
1950+
midIt = parIt;
1951+
1952+
while (parIt != m_Particles.end()) {
1953+
Vector parPos((*parIt)->GetPos());
1954+
Material const * terrMat = g_SceneMan.GetMaterialFromID(g_SceneMan.GetTerrain()->GetMaterialPixel(parPos.GetFloorIntX(), parPos.GetFloorIntY()));
1955+
int piling = (*parIt)->GetMaterial()->GetPiling();
1956+
if (piling > 0) {
1957+
for (int s = 0; terrMat->GetIndex() == (*parIt)->GetMaterial()->GetIndex() && s < piling; ++s) {
1958+
if ((piling - s) % 2 == 0) {
1959+
parPos.m_Y -= 1.0F;
1960+
} else {
1961+
parPos.m_X += (RandomNum() >= 0.5F ? 1.0F : -1.0F);
19671962
}
1968-
(*parIt)->SetPos(parPos);
1963+
terrMat = g_SceneMan.GetMaterialFromID(g_SceneMan.GetTerrain()->GetMaterialPixel(parPos.GetFloorIntX(), parPos.GetFloorIntY()));
19691964
}
1970-
g_SceneMan.GetTerrain()->ApplyMovableObject(*parIt);
1965+
(*parIt)->SetPos(parPos.GetFloored());
19711966
}
1972-
delete *(parIt++);
1973-
}
1974-
m_Particles.erase(midIt, m_Particles.end());
1975-
}
1967+
if ((*parIt)->GetDrawPriority() >= terrMat->GetPriority()) { g_SceneMan.GetTerrain()->ApplyMovableObject(*parIt); }
1968+
delete *(parIt++);
1969+
}
1970+
m_Particles.erase(midIt, m_Particles.end());
1971+
}
19761972

19771973
release_bitmap(g_SceneMan.GetTerrain()->GetMaterialBitmap());
19781974

0 commit comments

Comments
 (0)