diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index e92324ad..6bdcbbe7 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -535,22 +535,13 @@ namespace Components Maps::Maps() { - // Set AABBTree - //Utils::Hook::Nop(0x54A575, 2); - //Utils::Hook::Nop(0x54A589, 2); - //Utils::Hook::Set(0x54A506, 0xE990); - - // Reset while drawing - //Utils::Hook::Nop(0x542073, 4); - //Utils::Hook::Nop(0x54209B, 4); - //Utils::Hook::Nop(0x541FAB, 4); - - // Reset dpvs - //Utils::Hook::Nop(0x5185A3, 5); - Dvar::OnInit([]() { - Dvar::Register("r_forceForwardModels", false, 0, "Force drawing all static models in front of the player"); + bool value = false; +#ifdef DEBUG + value = true; +#endif + Dvar::Register("r_disableModelWorkaround", value, 0, "Disable static model drawing workaround for custom maps"); }); // Hook R_ClearDpvsSceneView to force drawing all models in front of us @@ -559,7 +550,7 @@ namespace Components Utils::Hook::Call(0x518530)(); // R_ClearDpvsSceneView Game::GfxWorld*& gameWorld = *reinterpret_cast(0x66DEE94); - if (!Game::CL_IsCgameInitialized() || !gameWorld || !Dvar::Var("r_forceForwardModels").get()) return; + if (!Game::CL_IsCgameInitialized() || !gameWorld || Dvar::Var("r_disableModelWorkaround").get() || gameWorld->mapVtxChecksum != 0xDEADBEEF) return; Game::vec3_t _forward, _right; Game::AngleVectors(reinterpret_cast(0x85F650), _forward, _right, nullptr); @@ -575,31 +566,29 @@ namespace Components { float* _origin = gameWorld->dpvs.smodelDrawInsts[i].placement.origin; glm::vec2 modelOrigin(_origin[0], _origin[1]); - glm::mat2x2 matrix(right[0], -(forward[0]), right[1], -(forward[1])); - // If matrix is singular just draw the models - if (glm::determinant(matrix) != 0) + if ((selfOrigin - modelOrigin).length() <= gameWorld->dpvs.smodelDrawInsts[i].cullDist * 1.0f) { - glm::mat2x2 invMatrix = glm::inverse(matrix); - glm::vec2 solve = modelOrigin - selfOrigin; - glm::vec2 result = invMatrix * solve; - glm::vec2 path = modelOrigin - (selfOrigin + (result[0] * right)); + // If matrix is singular just draw the models + glm::mat2x2 matrix(right[0], -(forward[0]), right[1], -(forward[1])); + if (glm::determinant(matrix) != 0) + { + glm::mat2x2 invMatrix = glm::inverse(matrix); + glm::vec2 solve = modelOrigin - selfOrigin; + glm::vec2 result = invMatrix * solve; + glm::vec2 path = modelOrigin - (selfOrigin + (result[0] * right)); - // Compare signs and skip to the next model if they don't equal - if ((path[0] < 0) == (forward[0] >= 0) && (path[1] < 0) == (forward[1] >= 0)) continue; + // Compare signs and skip to the next model if they don't equal + if ((path[0] < 0) == (forward[0] >= 0) && (path[1] < 0) == (forward[1] >= 0)) continue; + } + + gameWorld->dpvs.smodelVisData[0][i] = 1; + gameWorld->dpvs.smodelVisData[1][i] = 1; + gameWorld->dpvs.smodelVisData[2][i] = 1; } - - gameWorld->dpvs.smodelVisData[0][i] = 1; - gameWorld->dpvs.smodelVisData[1][i] = 1; - gameWorld->dpvs.smodelVisData[2][i] = 1; } }, HOOK_CALL).install()->quick(); - Command::Add("skipModel", [](Command::Params*) - { - Utils::Hook::Nop(0x541F02, 6); - }); - Dvar::OnInit([] () { Dvar::Register("isDlcInstalled_All", false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); diff --git a/src/Utils/Entities.cpp b/src/Utils/Entities.cpp index ad72bd14..b47e960a 100644 --- a/src/Utils/Entities.cpp +++ b/src/Utils/Entities.cpp @@ -85,7 +85,7 @@ namespace Utils { for (auto i = this->entities.begin(); i != this->entities.end();) { - if (i->find("weaponinfo") != i->end()) + if (i->find("weaponinfo") != i->end() || (i->find("targetname") != i->end() && (*i)["targetname"] == "oldschool_pickup"s)) { if (!keepTurrets || i->find("classname") == i->end() || (*i)["classname"] != "misc_turret"s) {