From 31138cf92fde07957799c44670504bd795e5f952 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:10:55 +0300 Subject: [PATCH 01/10] fix cylinder marker --- Client/mods/deathmatch/logic/CClientMarker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index d193ab1823d..6a038d282b1 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -469,7 +469,7 @@ void CClientMarker::CreateOfType(int iType) CClient3DMarker* p3DMarker = new CClient3DMarker(this); p3DMarker->Set3DMarkerType(CClient3DMarker::TYPE_CYLINDER); m_pMarker = p3DMarker; - m_pCollision = new CClientColCircle(g_pClientGame->GetManager(), NULL, vecOrigin, GetSize()); + m_pCollision = new CClientColSphere(g_pClientGame->GetManager(), NULL, vecOrigin, GetSize()); m_pCollision->m_pOwningMarker = this; m_pCollision->SetHitCallback(this); break; From 3ea5e926ffc3e789aafaf45fa42266f7d39ab8aa Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:18:59 +0300 Subject: [PATCH 02/10] shapes --- Client/mods/deathmatch/logic/CClientColTube.h | 1 + .../mods/deathmatch/logic/CClientMarker.cpp | 46 ++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CClientColTube.h b/Client/mods/deathmatch/logic/CClientColTube.h index ed6a345f3db..72958bbcb0c 100644 --- a/Client/mods/deathmatch/logic/CClientColTube.h +++ b/Client/mods/deathmatch/logic/CClientColTube.h @@ -35,6 +35,7 @@ class CClientColTube final : public CClientColShape m_fHeight = fHeight; SizeChanged(); }; + float adjustSize(float fSize); protected: float m_fRadius; diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index 6a038d282b1..6cfec831aff 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -298,10 +298,44 @@ float CClientMarker::GetSize() const return m_pMarker->GetSize(); } +float CClientColTube::adjustSize(float fSize) +{ + float size = fSize; + float nextValue = 0.0f; + float initialValue = 2.4f; // Replace with your actual initial value + float increment = 1.03f; + double epsilon = std::numeric_limits::epsilon();// Very small epsilon value + + if (std::abs(fSize - std::round(fSize)) > epsilon) + { + size = std::floor(fSize - 0.5f); // Round non-integer values + } + + if (std::fmod(size, 2.0) == 0.0) // check for even + { + nextValue = (size / 2.0f) + 0.15f; + } + else if (std::fmod(size, 2.0) == 1.0) //check for odd + { + nextValue = initialValue + increment * ((size - 5.0f) / 2.0f); + } + else + { + nextValue = initialValue + 1.1f * ((size - 5.0f) / 2.0f); // check for float values + } + return nextValue; +} + + void CClientMarker::SetSize(float fSize) { + + std::string str1 = std::to_string(m_pCollision->GetShapeType()); + CStaticFunctionDefinitions::OutputConsole(str1.c_str()); + switch (m_pCollision->GetShapeType()) { + case COLSHAPE_CIRCLE: { CClientColCircle* pShape = static_cast(m_pCollision); @@ -314,7 +348,17 @@ void CClientMarker::SetSize(float fSize) pShape->SetRadius(fSize); break; } + case COLSHAPE_TUBE: + { + CClientColTube* pShape = static_cast(m_pCollision); + pShape->SetRadius(pShape->adjustSize(fSize)); + pShape->SetHeight(fSize); + CStaticFunctionDefinitions::OutputConsole("tube"); + + break; + } } + m_pMarker->SetSize(fSize); } @@ -469,7 +513,7 @@ void CClientMarker::CreateOfType(int iType) CClient3DMarker* p3DMarker = new CClient3DMarker(this); p3DMarker->Set3DMarkerType(CClient3DMarker::TYPE_CYLINDER); m_pMarker = p3DMarker; - m_pCollision = new CClientColSphere(g_pClientGame->GetManager(), NULL, vecOrigin, GetSize()); + m_pCollision = new CClientColTube(g_pClientGame->GetManager(), NULL, vecOrigin, GetSize(), GetSize()); m_pCollision->m_pOwningMarker = this; m_pCollision->SetHitCallback(this); break; From b43321f19594968a4aadb1713ade577e1ac146e1 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:30:40 +0300 Subject: [PATCH 03/10] not used --- Client/mods/deathmatch/logic/CClientMarker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index 6cfec831aff..c3cdb09f1da 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -321,7 +321,7 @@ float CClientColTube::adjustSize(float fSize) } else { - nextValue = initialValue + 1.1f * ((size - 5.0f) / 2.0f); // check for float values + } return nextValue; } From 9b93b90002085495c7003b2f4f5867a7bfc0bd33 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:12:30 +0300 Subject: [PATCH 04/10] adjust float correctly --- Client/mods/deathmatch/logic/CClientMarker.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index c3cdb09f1da..9e1033393b2 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -304,13 +304,9 @@ float CClientColTube::adjustSize(float fSize) float nextValue = 0.0f; float initialValue = 2.4f; // Replace with your actual initial value float increment = 1.03f; - double epsilon = std::numeric_limits::epsilon();// Very small epsilon value - - if (std::abs(fSize - std::round(fSize)) > epsilon) - { - size = std::floor(fSize - 0.5f); // Round non-integer values - } + + if (std::fmod(size, 2.0) == 0.0) // check for even { nextValue = (size / 2.0f) + 0.15f; @@ -321,7 +317,7 @@ float CClientColTube::adjustSize(float fSize) } else { - + nextValue = (size / 2.0f) + 0.15f; } return nextValue; } From 8c05fa6269bd5ad0ec4e1301f6c5c6dc761c2019 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Wed, 12 Jun 2024 20:00:15 +0300 Subject: [PATCH 05/10] cleaning --- .../mods/deathmatch/logic/CClientMarker.cpp | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index 9e1033393b2..40f7f2b42be 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -300,38 +300,27 @@ float CClientMarker::GetSize() const float CClientColTube::adjustSize(float fSize) { - float size = fSize; - float nextValue = 0.0f; - float initialValue = 2.4f; // Replace with your actual initial value - float increment = 1.03f; - - - - if (std::fmod(size, 2.0) == 0.0) // check for even + // Replace with your actual initial value + + if (std::fmod(fSize, 2.0) == 0.0) // check for even { - nextValue = (size / 2.0f) + 0.15f; + fSize = (fSize / 2.0f) + 0.15f; } - else if (std::fmod(size, 2.0) == 1.0) //check for odd + else if (std::fmod(fSize, 2.0) == 1.0) // check for odd { - nextValue = initialValue + increment * ((size - 5.0f) / 2.0f); + fSize = 2.4f + 1.03f * ((fSize - 5.0f) / 2.0f); } else { - nextValue = (size / 2.0f) + 0.15f; + fSize = (fSize / 2.0f) + 0.15f; //check for float } - return nextValue; + return fSize; } - void CClientMarker::SetSize(float fSize) { - - std::string str1 = std::to_string(m_pCollision->GetShapeType()); - CStaticFunctionDefinitions::OutputConsole(str1.c_str()); - switch (m_pCollision->GetShapeType()) { - case COLSHAPE_CIRCLE: { CClientColCircle* pShape = static_cast(m_pCollision); @@ -349,8 +338,6 @@ void CClientMarker::SetSize(float fSize) CClientColTube* pShape = static_cast(m_pCollision); pShape->SetRadius(pShape->adjustSize(fSize)); pShape->SetHeight(fSize); - CStaticFunctionDefinitions::OutputConsole("tube"); - break; } } From 94a462239499f35c59fc452fa75ba2068d9c5f2a Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Wed, 12 Jun 2024 20:17:51 +0300 Subject: [PATCH 06/10] fixes for size --- Client/mods/deathmatch/logic/CClientMarker.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index 40f7f2b42be..db1b49946b6 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -300,19 +300,18 @@ float CClientMarker::GetSize() const float CClientColTube::adjustSize(float fSize) { - // Replace with your actual initial value - - if (std::fmod(fSize, 2.0) == 0.0) // check for even + + if (std::fmod(fSize, 2.0) == 0.0) // check for even { - fSize = (fSize / 2.0f) + 0.15f; + fSize = (fSize / 2.0f) + 0.14f; } - else if (std::fmod(fSize, 2.0) == 1.0) // check for odd + else if (std::fmod(fSize, 2.0) == 1.0) // check for odd { fSize = 2.4f + 1.03f * ((fSize - 5.0f) / 2.0f); } else { - fSize = (fSize / 2.0f) + 0.15f; //check for float + fSize = (fSize / 2.0f) + 0.15f; //check for float } return fSize; } From a78e88bf90158d46c3fd5e8b71962fffe6a92d50 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:33:38 +0300 Subject: [PATCH 07/10] serverside --- Server/mods/deathmatch/logic/CColTube.h | 1 + Server/mods/deathmatch/logic/CMarker.cpp | 36 +++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Server/mods/deathmatch/logic/CColTube.h b/Server/mods/deathmatch/logic/CColTube.h index 9b63391d9cd..b590f33f050 100644 --- a/Server/mods/deathmatch/logic/CColTube.h +++ b/Server/mods/deathmatch/logic/CColTube.h @@ -36,6 +36,7 @@ class CColTube : public CColShape m_fHeight = fHeight; SizeChanged(); }; + float adjustSize(float fSize); protected: bool ReadSpecialData(const int iLine) override; diff --git a/Server/mods/deathmatch/logic/CMarker.cpp b/Server/mods/deathmatch/logic/CMarker.cpp index 0fc93ba76fb..5ac1a0065a8 100644 --- a/Server/mods/deathmatch/logic/CMarker.cpp +++ b/Server/mods/deathmatch/logic/CMarker.cpp @@ -14,6 +14,7 @@ #include "CMarkerManager.h" #include "CColCircle.h" #include "CColSphere.h" +#include "CColTube.h" #include "CResource.h" #include "CLogger.h" #include "Utils.h" @@ -353,6 +354,23 @@ void CMarker::Callback_OnCollisionDestroy(CColShape* pCollision) m_pCollision = NULL; } +float CColTube::adjustSize(float fSize) +{ + if (std::fmod(fSize, 2.0) == 0.0) // check for even + { + fSize = (fSize / 2.0f) + 0.14f; + } + else if (std::fmod(fSize, 2.0) == 1.0) // check for odd + { + fSize = 2.4f + 1.03f * ((fSize - 5.0f) / 2.0f); + } + else + { + fSize = (fSize / 2.0f) + 0.15f; // check for float + } + return fSize; +} + void CMarker::UpdateCollisionObject(unsigned char ucOldType) { // Different type than before? @@ -365,15 +383,19 @@ void CMarker::UpdateCollisionObject(unsigned char ucOldType) { if (m_pCollision) g_pGame->GetElementDeleter()->Delete(m_pCollision); - - m_pCollision = new CColCircle(m_pColManager, nullptr, m_vecPosition, m_fSize, true); + m_pCollision = new CColCircle(m_pColManager, nullptr, m_vecPosition, m_fSize, true); + } + else if (m_ucType == CMarker::TYPE_CYLINDER) + { + if (m_pCollision) + g_pGame->GetElementDeleter()->Delete(m_pCollision); + m_pCollision = new CColTube(m_pColManager, nullptr, m_vecPosition, m_fSize, m_fSize); } else if (ucOldType == CMarker::TYPE_CHECKPOINT) { if (m_pCollision) g_pGame->GetElementDeleter()->Delete(m_pCollision); - - m_pCollision = new CColSphere(m_pColManager, nullptr, m_vecPosition, m_fSize, true); + m_pCollision = new CColSphere(m_pColManager, nullptr, m_vecPosition, m_fSize, true); } m_pCollision->SetCallback(this); @@ -386,6 +408,12 @@ void CMarker::UpdateCollisionObject(unsigned char ucOldType) { static_cast(m_pCollision)->SetRadius(m_fSize); } + else if (m_ucType == CMarker::TYPE_CYLINDER) + { + CColTube* pShape = static_cast(m_pCollision); + pShape->SetRadius(pShape->adjustSize(m_fSize)); + pShape->SetHeight(m_fSize); + } else { static_cast(m_pCollision)->SetRadius(m_fSize); From 5d08090bd0e2297147c10580ad19de2696e430e1 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 16 Jun 2024 14:41:28 +0300 Subject: [PATCH 08/10] function name fixes --- Client/mods/deathmatch/logic/CClientColTube.h | 2 +- Client/mods/deathmatch/logic/CClientMarker.cpp | 4 ++-- Server/mods/deathmatch/logic/CColTube.h | 2 +- Server/mods/deathmatch/logic/CMarker.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Client/mods/deathmatch/logic/CClientColTube.h b/Client/mods/deathmatch/logic/CClientColTube.h index 72958bbcb0c..bf773533ca4 100644 --- a/Client/mods/deathmatch/logic/CClientColTube.h +++ b/Client/mods/deathmatch/logic/CClientColTube.h @@ -35,7 +35,7 @@ class CClientColTube final : public CClientColShape m_fHeight = fHeight; SizeChanged(); }; - float adjustSize(float fSize); + float AdjustSize(float fSize); protected: float m_fRadius; diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index db1b49946b6..5fb11eb9819 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -298,7 +298,7 @@ float CClientMarker::GetSize() const return m_pMarker->GetSize(); } -float CClientColTube::adjustSize(float fSize) +float CClientColTube::AdjustSize(float fSize) { if (std::fmod(fSize, 2.0) == 0.0) // check for even @@ -335,7 +335,7 @@ void CClientMarker::SetSize(float fSize) case COLSHAPE_TUBE: { CClientColTube* pShape = static_cast(m_pCollision); - pShape->SetRadius(pShape->adjustSize(fSize)); + pShape->SetRadius(pShape->AdjustSize(fSize)); pShape->SetHeight(fSize); break; } diff --git a/Server/mods/deathmatch/logic/CColTube.h b/Server/mods/deathmatch/logic/CColTube.h index b590f33f050..d008098ec6d 100644 --- a/Server/mods/deathmatch/logic/CColTube.h +++ b/Server/mods/deathmatch/logic/CColTube.h @@ -36,7 +36,7 @@ class CColTube : public CColShape m_fHeight = fHeight; SizeChanged(); }; - float adjustSize(float fSize); + float AdjustSize(float fSize); protected: bool ReadSpecialData(const int iLine) override; diff --git a/Server/mods/deathmatch/logic/CMarker.cpp b/Server/mods/deathmatch/logic/CMarker.cpp index 5ac1a0065a8..56afd620771 100644 --- a/Server/mods/deathmatch/logic/CMarker.cpp +++ b/Server/mods/deathmatch/logic/CMarker.cpp @@ -354,7 +354,7 @@ void CMarker::Callback_OnCollisionDestroy(CColShape* pCollision) m_pCollision = NULL; } -float CColTube::adjustSize(float fSize) +float CColTube::AdjustSize(float fSize) { if (std::fmod(fSize, 2.0) == 0.0) // check for even { @@ -411,7 +411,7 @@ void CMarker::UpdateCollisionObject(unsigned char ucOldType) else if (m_ucType == CMarker::TYPE_CYLINDER) { CColTube* pShape = static_cast(m_pCollision); - pShape->SetRadius(pShape->adjustSize(m_fSize)); + pShape->SetRadius(pShape->AdjustSize(m_fSize)); pShape->SetHeight(m_fSize); } else From 969e659009782ca5e4bb22f173222b53d8506698 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 16 Jun 2024 18:08:58 +0300 Subject: [PATCH 09/10] simplify formula --- Client/mods/deathmatch/logic/CClientMarker.cpp | 14 +------------- Server/mods/deathmatch/logic/CMarker.cpp | 13 +------------ 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index 5fb11eb9819..94c953a02e0 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -300,19 +300,7 @@ float CClientMarker::GetSize() const float CClientColTube::AdjustSize(float fSize) { - - if (std::fmod(fSize, 2.0) == 0.0) // check for even - { - fSize = (fSize / 2.0f) + 0.14f; - } - else if (std::fmod(fSize, 2.0) == 1.0) // check for odd - { - fSize = 2.4f + 1.03f * ((fSize - 5.0f) / 2.0f); - } - else - { - fSize = (fSize / 2.0f) + 0.15f; //check for float - } + fSize = (fSize / 2.0f) + 0.15f; return fSize; } diff --git a/Server/mods/deathmatch/logic/CMarker.cpp b/Server/mods/deathmatch/logic/CMarker.cpp index 56afd620771..65882ab1aef 100644 --- a/Server/mods/deathmatch/logic/CMarker.cpp +++ b/Server/mods/deathmatch/logic/CMarker.cpp @@ -356,18 +356,7 @@ void CMarker::Callback_OnCollisionDestroy(CColShape* pCollision) float CColTube::AdjustSize(float fSize) { - if (std::fmod(fSize, 2.0) == 0.0) // check for even - { - fSize = (fSize / 2.0f) + 0.14f; - } - else if (std::fmod(fSize, 2.0) == 1.0) // check for odd - { - fSize = 2.4f + 1.03f * ((fSize - 5.0f) / 2.0f); - } - else - { - fSize = (fSize / 2.0f) + 0.15f; // check for float - } + fSize = (fSize / 2.0f) + 0.15f; return fSize; } From 70195e1cc0efe57781118c92d34a7cccfca4e081 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 16 Jun 2024 18:11:58 +0300 Subject: [PATCH 10/10] return directly --- Client/mods/deathmatch/logic/CClientMarker.cpp | 3 +-- Server/mods/deathmatch/logic/CMarker.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Client/mods/deathmatch/logic/CClientMarker.cpp b/Client/mods/deathmatch/logic/CClientMarker.cpp index 94c953a02e0..36d3ac9a4b2 100644 --- a/Client/mods/deathmatch/logic/CClientMarker.cpp +++ b/Client/mods/deathmatch/logic/CClientMarker.cpp @@ -300,8 +300,7 @@ float CClientMarker::GetSize() const float CClientColTube::AdjustSize(float fSize) { - fSize = (fSize / 2.0f) + 0.15f; - return fSize; + return (fSize / 2.0f) + 0.15f; } void CClientMarker::SetSize(float fSize) diff --git a/Server/mods/deathmatch/logic/CMarker.cpp b/Server/mods/deathmatch/logic/CMarker.cpp index 65882ab1aef..1f0566588f1 100644 --- a/Server/mods/deathmatch/logic/CMarker.cpp +++ b/Server/mods/deathmatch/logic/CMarker.cpp @@ -356,8 +356,7 @@ void CMarker::Callback_OnCollisionDestroy(CColShape* pCollision) float CColTube::AdjustSize(float fSize) { - fSize = (fSize / 2.0f) + 0.15f; - return fSize; + return (fSize / 2.0f) + 0.15f; } void CMarker::UpdateCollisionObject(unsigned char ucOldType)