From 37172134a4d12d4025df68f023cf0f70902d653a Mon Sep 17 00:00:00 2001 From: LightCat Date: Wed, 17 Apr 2019 17:05:28 +0200 Subject: [PATCH] Improve FPS by clearing item Manager every round, fix a LTO/Clang compile issue, add cat_oob_slow --- data/cliplist.txt | 4 ++-- include/itemtypes.hpp | 10 +++++----- src/hacks/Misc.cpp | 12 ++++++++---- src/hooks/CreateMove.cpp | 4 ++-- src/itemtypes.cpp | 1 + 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/data/cliplist.txt b/data/cliplist.txt index 9b1f8cf2..a1fd93e7 100644 --- a/data/cliplist.txt +++ b/data/cliplist.txt @@ -14,7 +14,7 @@ -1927.023193f, -936.055847f, -255.970061f, 2.673917f, 179.936523f, "ctf_turbine" // Swiftwater 5543.948730f, -1527.988037f, -1023.96875f, 23.115799f, -0.012952f, "pl_swiftwater_final1" -2636.031250f, -1126.089478f, 13.124457f, -1130.14154f, 179.843811f, "pl_swiftwater_final1" +2636.031250f, -1126.089478f, 13.124457f, 0.0f, 179.843811f, "pl_swiftwater_final1" // Thundermountain // Phase 1 -1068.001587f, -3724.079834f, 132.000061f - 68.000061f, 17.606197f, 0.118330f, "pl_thundermountain" @@ -24,4 +24,4 @@ // Phase 3 2191.972900f, 3353.798340f, 452.031311f - 68.000061f, 12.601318f, 89.972534f, "pl_thundermountain" 4889.611328f, 4287.997070f, 576.031250f, 11.911232f, 179.998672f, "pl_thundermountain" --3327.432129f, -928.000366f, -311.968750f, 7.452800f, 89.949173f, "cp_mossrock" \ No newline at end of file +-3328.097656f, -928.001221f, -311.968750f, -1.423861f, 89.814667f,"cp_mossrock" \ No newline at end of file diff --git a/include/itemtypes.hpp b/include/itemtypes.hpp index f20b57dd..306abd5f 100644 --- a/include/itemtypes.hpp +++ b/include/itemtypes.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -139,8 +139,8 @@ public: void RegisterItem(std::string modelpath, k_EItemType type); k_EItemType GetItemType(CachedEntity *entity); - std::map models; - std::map map; + std::unordered_map models; + std::unordered_map map; }; class ItemManager @@ -151,10 +151,10 @@ public: void RegisterSpecialMapping(ItemCheckerFn fn, k_EItemType type); k_EItemType GetItemType(CachedEntity *ent); - std::map special_map; + std::unordered_map special_map; std::vector specials; ItemModelMapper mapper_special; ItemModelMapper mapper; }; -extern ItemManager g_ItemManager; \ No newline at end of file +extern ItemManager g_ItemManager; diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index 8bbf030b..2b800f1c 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -144,16 +144,20 @@ int getCarriedBuilding() return -1; } static settings::Button oob_helper{ "oob_helper", "" }; +static settings::Bool oob_helper_slow{ "oob_helper_slow", "true" }; void CreateMove() { if (oob_helper && oob_helper.isKeyDown()) { if (CE_GOOD(LOCAL_E) && LOCAL_E->m_bAlivePlayer()) { - if (current_user_cmd->sidemove) - current_user_cmd->sidemove = current_user_cmd->sidemove < 0.0f ? -1.0001f : 1.0001f; - if (current_user_cmd->forwardmove) - current_user_cmd->forwardmove = current_user_cmd->forwardmove < 0.0f ? -1.0001f : 1.0001f; + if (oob_helper_slow) + { + if (current_user_cmd->sidemove) + current_user_cmd->sidemove = current_user_cmd->sidemove < 0.0f ? -1.0001f : 1.0001f; + if (current_user_cmd->forwardmove) + current_user_cmd->forwardmove = current_user_cmd->forwardmove < 0.0f ? -1.0001f : 1.0001f; + } int building_idx = getCarriedBuilding(); if (building_idx != -1) { diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 0f0ca9cd..23d62b71 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -129,8 +129,8 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs #define TIME_TO_TICKS(dt) ((int) (0.5f + (float) (dt) / TICK_INTERVAL)) #define TICKS_TO_TIME(t) (TICK_INTERVAL * (t)) #define ROUND_TO_TICKS(t) (TICK_INTERVAL * TIME_TO_TICKS(t)) - uintptr_t **fp; - __asm__("mov %%ebp, %0" : "=r"(fp)); + volatile uintptr_t **fp; + __asm__ volatile("mov %%ebp, %0" : "=r"(fp)); bSendPackets = reinterpret_cast(**fp - 8); g_Settings.is_create_move = true; diff --git a/src/itemtypes.cpp b/src/itemtypes.cpp index 6f3d0370..a5ac1234 100644 --- a/src/itemtypes.cpp +++ b/src/itemtypes.cpp @@ -219,3 +219,4 @@ k_EItemType ItemModelMapper::GetItemType(CachedEntity *entity) } ItemManager g_ItemManager; +static InitRoutine init([]() { EC::Register(EC::LevelInit, []() { g_ItemManager = ItemManager{}; }, "clear_itemtypes"); });