From 4ddbfcb6ad2a0d071fa133cad8a0dc5f39328dd1 Mon Sep 17 00:00:00 2001 From: SmileyAG Date: Mon, 27 Nov 2023 18:24:58 +0400 Subject: [PATCH 1/6] Advanced checkpoints --- BunnymodXT/cvars.hpp | 3 + BunnymodXT/hud_custom.cpp | 19 +++ BunnymodXT/modules/ClientDLL.cpp | 3 + BunnymodXT/modules/HwDLL.cpp | 202 +++++++++++++++++++++++++++---- BunnymodXT/modules/HwDLL.hpp | 22 +++- 5 files changed, 223 insertions(+), 26 deletions(-) diff --git a/BunnymodXT/cvars.hpp b/BunnymodXT/cvars.hpp index fb816c52..1154b193 100644 --- a/BunnymodXT/cvars.hpp +++ b/BunnymodXT/cvars.hpp @@ -130,6 +130,9 @@ X(bxt_hud_quickgauss, "0") \ X(bxt_hud_quickgauss_offset, "") \ X(bxt_hud_quickgauss_anchor, "0.5 0") \ + X(bxt_hud_checkpoint, "0") \ + X(bxt_hud_checkpoint_offset, "") \ + X(bxt_hud_checkpoint_anchor, "0.5 0") \ X(bxt_hud_velocity, "0") \ X(bxt_hud_velocity_offset, "") \ X(bxt_hud_velocity_anchor, "1 0") \ diff --git a/BunnymodXT/hud_custom.cpp b/BunnymodXT/hud_custom.cpp index 74d6cc8d..bf19a269 100644 --- a/BunnymodXT/hud_custom.cpp +++ b/BunnymodXT/hud_custom.cpp @@ -528,6 +528,24 @@ namespace CustomHud } } + static void DrawCheckpoint(float flTime) + { + if (CVars::bxt_hud_checkpoint.GetBool()) + { + int x, y; + GetPosition(CVars::bxt_hud_checkpoint_offset, CVars::bxt_hud_checkpoint_anchor, &x, &y, 150, (si.iCharHeight * 3) + 1); + + std::ostringstream out; + out.setf(std::ios::fixed); + out.precision(precision); + + auto &hw = HwDLL::GetInstance(); + out << "Current / total checkpoints: " << hw.ch_checkpoint_current << " " << hw.ch_checkpoint_total << "\n"; + + DrawMultilineString(x, y, out.str()); + } + } + static void DrawOrigin(float flTime) { if (CVars::bxt_hud_origin.GetBool()) @@ -1738,6 +1756,7 @@ namespace CustomHud GetAccurateInfo(); DrawQuickGauss(flTime); + DrawCheckpoint(flTime); DrawHealth(flTime); DrawArmor(flTime); DrawWaterlevel(flTime); diff --git a/BunnymodXT/modules/ClientDLL.cpp b/BunnymodXT/modules/ClientDLL.cpp index 7fc96a29..4d33a99a 100644 --- a/BunnymodXT/modules/ClientDLL.cpp +++ b/BunnymodXT/modules/ClientDLL.cpp @@ -987,6 +987,9 @@ void ClientDLL::RegisterCVarsAndCommands() REG(bxt_hud_quickgauss); REG(bxt_hud_quickgauss_offset); REG(bxt_hud_quickgauss_anchor); + REG(bxt_hud_checkpoint); + REG(bxt_hud_checkpoint_offset); + REG(bxt_hud_checkpoint_anchor); REG(bxt_hud_velocity); REG(bxt_hud_velocity_offset); REG(bxt_hud_velocity_anchor); diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index 0a80fa2f..d35bd88e 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -820,7 +820,10 @@ void HwDLL::Clear() ch_hook = false; ch_hook_point = Vector(); ch_checkpoint_is_set = false; - ch_checkpoint_is_duck = false; + ch_checkpoint_origin.clear(); + ch_checkpoint_vel.clear(); + ch_checkpoint_viewangles.clear(); + ch_checkpoint_is_duck.clear(); tas_editor_mode = TASEditorMode::DISABLED; @@ -3319,7 +3322,7 @@ void HwDLL::ChHookPlayer() { struct HwDLL::Cmd_BXT_CH_CheckPoint_Create { - NO_USAGE(); + USAGE("Usage: bxt_ch_checkpoint_create\n"); static void handler() { @@ -3345,35 +3348,66 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Create return; } + hw.ch_checkpoint_total++; + hw.ch_checkpoint_origin.emplace_back(pl->v.origin); + hw.ch_checkpoint_vel.emplace_back(pl->v.velocity); + hw.ch_checkpoint_viewangles.emplace_back(pl->v.v_angle); + hw.ch_checkpoint_is_duck.emplace_back(is_duck); hw.ch_checkpoint_is_set = true; - hw.ch_checkpoint_origin = pl->v.origin; - hw.ch_checkpoint_vel = pl->v.velocity; - hw.ch_checkpoint_viewangles = pl->v.v_angle; - hw.ch_checkpoint_is_duck = is_duck; } }; struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo { - NO_USAGE(); + USAGE("Usage: bxt_ch_checkpoint_goto [id]\n Go to the last checkpoint.\n If an id is given, go to the checkpoint with the given id.\n"); static void handler() { auto &hw = HwDLL::GetInstance(); if (!hw.ch_checkpoint_is_set) + { + hw.ch_checkpoint_id_goto_specified = 0; // Reset ID return; + } auto &cl = ClientDLL::GetInstance(); auto pl = hw.GetPlayerEdict(); - if (!pl) + if (!pl || hw.ch_checkpoint_is_duck.empty()) + { + hw.ch_checkpoint_id_goto_specified = 0; // Reset ID return; + } + + Vector cp_origin; + Vector cp_vel; + Vector cp_viewangles; + bool cp_is_duck; - cl.pEngfuncs->SetViewAngles(hw.ch_checkpoint_viewangles); + if ((hw.ch_checkpoint_id_goto_specified > 0) && (hw.ch_checkpoint_is_duck.size() >= hw.ch_checkpoint_id_goto_specified)) // If ID is more than 0 and the size of std::vector is greater than the specified ID, we are fine! + { + cp_origin = *(hw.ch_checkpoint_origin.begin() + (hw.ch_checkpoint_id_goto_specified - 1)); + cp_vel = *(hw.ch_checkpoint_vel.begin() + (hw.ch_checkpoint_id_goto_specified - 1)); + cp_viewangles = *(hw.ch_checkpoint_viewangles.begin() + (hw.ch_checkpoint_id_goto_specified - 1)); + cp_is_duck = *(hw.ch_checkpoint_is_duck.begin() + (hw.ch_checkpoint_id_goto_specified - 1)); + hw.ch_checkpoint_current = hw.ch_checkpoint_id_goto_specified; + } + else // Otherwise we will use the last element + { + cp_origin = hw.ch_checkpoint_origin.back(); + cp_vel = hw.ch_checkpoint_vel.back(); + cp_viewangles = hw.ch_checkpoint_viewangles.back(); + cp_is_duck = hw.ch_checkpoint_is_duck.back(); + hw.ch_checkpoint_current = hw.ch_checkpoint_total; + } - if (hw.ch_checkpoint_is_duck) { + hw.ch_checkpoint_id_goto_specified = 0; // Reset ID + + cl.pEngfuncs->SetViewAngles(cp_viewangles); + + if (cp_is_duck) { pl->v.flags |= FL_DUCKING; pl->v.button |= IN_DUCK; } @@ -3385,15 +3419,135 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo pl->v.punchangle = Vector(0, 0, 0); if (CVars::bxt_ch_checkpoint_with_vel.GetBool()) - pl->v.velocity = hw.ch_checkpoint_vel; + pl->v.velocity = cp_vel; - pl->v.origin = hw.ch_checkpoint_origin; + pl->v.origin = cp_origin; // for CS 1.6 stamina reset - static bool is_cstrike = cl.DoesGameDirMatch("cstrike"); - if (is_cstrike) + if (hw.is_cstrike_dir) pl->v.fuser2 = 0; } + + static void handler(unsigned long id) + { + HwDLL::GetInstance().ch_checkpoint_id_goto_specified = id; // Set ID + handler(); + } +}; + +struct HwDLL::Cmd_BXT_CH_CheckPoint_Current +{ + USAGE("Usage: bxt_ch_checkpoint_current\n"); + + static void handler() + { + auto &hw = HwDLL::GetInstance(); + + std::ostringstream ss; + ss << "bxt_ch_checkpoint_goto " << hw.ch_checkpoint_current << "\n"; + hw.ORIG_Cbuf_AddText(ss.str().c_str()); + } +}; + +struct HwDLL::Cmd_BXT_CH_CheckPoint_Reset +{ + USAGE("Usage: bxt_ch_checkpoint_reset\n"); + + static void handler() + { + auto &hw = HwDLL::GetInstance(); + + hw.ch_checkpoint_origin.clear(); + hw.ch_checkpoint_vel.clear(); + hw.ch_checkpoint_viewangles.clear(); + hw.ch_checkpoint_is_duck.clear(); + hw.ch_checkpoint_total = hw.ch_checkpoint_current = 0; + } +}; + +struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove +{ + USAGE("Usage: bxt_ch_checkpoint_remove [id]\n Deletes the last checkpoint.\n If an id is given, deletes the checkpoint with the given id.\n"); + + static void handler() + { + auto &hw = HwDLL::GetInstance(); + if (!hw.ch_checkpoint_is_duck.empty()) + { + int id; + if ((hw.ch_checkpoint_id_remove_specified > 0) && (hw.ch_checkpoint_is_duck.size() >= hw.ch_checkpoint_id_remove_specified)) // If ID is more than 0 and the size of std::vector is greater than the specified ID, we are fine! + id = static_cast(hw.ch_checkpoint_id_remove_specified); + else // Otherwise we will use the last element + id = hw.ch_checkpoint_total; + + if (hw.ch_checkpoint_current == id) // Is ID equal to the current checkpoint? Well, then decrement both counters! + { + hw.ch_checkpoint_current--; + hw.ch_checkpoint_total--; + } + else // Otherwise we will decrement only total counter + { + hw.ch_checkpoint_total--; + } + + hw.ch_checkpoint_origin.erase(hw.ch_checkpoint_origin.begin() + (id - 1)); + hw.ch_checkpoint_vel.erase(hw.ch_checkpoint_vel.begin() + (id - 1)); + hw.ch_checkpoint_viewangles.erase(hw.ch_checkpoint_viewangles.begin() + (id - 1)); + hw.ch_checkpoint_is_duck.erase(hw.ch_checkpoint_is_duck.begin() + (id - 1)); + } + + hw.ch_checkpoint_id_remove_specified = 0; // Reset ID + } + + static void handler(unsigned long id) + { + HwDLL::GetInstance().ch_checkpoint_id_remove_specified = id; // Set ID + handler(); + } +}; + +struct HwDLL::Cmd_BXT_CH_CheckPoint_Next +{ + USAGE("Usage: bxt_ch_checkpoint_next\n"); + + static void handler() + { + auto &hw = HwDLL::GetInstance(); + + if (!hw.ch_checkpoint_is_duck.empty()) + { + if (hw.ch_checkpoint_total > hw.ch_checkpoint_current) // Don't increment if next element is greater than total count + { + hw.ch_checkpoint_current++; + + std::ostringstream ss; + ss << "bxt_ch_checkpoint_goto " << hw.ch_checkpoint_current << "\n"; + hw.ORIG_Cbuf_AddText(ss.str().c_str()); + } + } + } +}; + +struct HwDLL::Cmd_BXT_CH_CheckPoint_Prev +{ + USAGE("Usage: bxt_ch_checkpoint_prev\n"); + + static void handler() + { + auto &hw = HwDLL::GetInstance(); + + if (!hw.ch_checkpoint_is_duck.empty()) + { + if (hw.ch_checkpoint_current > 1) // Don't decrement if we have less than 2 elements + { + hw.ch_checkpoint_current--; + + std::ostringstream ss; + ss << "bxt_ch_checkpoint_goto " << hw.ch_checkpoint_current << "\n"; + hw.ORIG_Cbuf_AddText(ss.str().c_str()); + } + } + } }; struct HwDLL::Cmd_BXT_CH_Get_Other_Player_Info @@ -5567,7 +5721,12 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded() wrapper::AddCheat, Handler>("+bxt_ch_hook"); wrapper::AddCheat, Handler>("-bxt_ch_hook"); wrapper::AddCheat>("bxt_ch_checkpoint_create"); - wrapper::AddCheat>("bxt_ch_checkpoint_goto"); + wrapper::AddCheat, Handler>("bxt_ch_checkpoint_goto"); + wrapper::AddCheat, Handler>("bxt_ch_checkpoint_remove"); + wrapper::AddCheat>("bxt_ch_checkpoint_reset"); + wrapper::AddCheat>("bxt_ch_checkpoint_next"); + wrapper::AddCheat>("bxt_ch_checkpoint_prev"); + wrapper::AddCheat>("bxt_ch_checkpoint_current"); wrapper::Add< Cmd_BXT_Set_Angles, Handler, @@ -6577,19 +6736,18 @@ HLStrafe::MovementVars HwDLL::GetMovementVars() vars.Bounce = CVars::sv_bounce.GetFloat(); vars.Bhopcap = CVars::bxt_bhopcap.GetBool(); - static bool is_paranoia = cl.DoesGameDirMatch("paranoia"); - static bool is_cstrike = cl.DoesGameDirMatch("cstrike"); - static bool is_czero = cl.DoesGameDirMatch("czero"); - static bool is_tfc = cl.DoesGameDirMatch("tfc"); + static bool is_paranoia_dir = cl.DoesGameDirMatch("paranoia"); + is_tfc_dir = cl.DoesGameDirMatch("tfc"); + is_cstrike_dir = cl.DoesGameDirMatch("cstrike") || cl.DoesGameDirMatch("czero"); - if (is_paranoia) + if (is_paranoia_dir) vars.Maxspeed = cl.pEngfuncs->GetClientMaxspeed() * CVars::sv_maxspeed.GetFloat() / 100.0f; // GetMaxSpeed is factor here else if (cl.pEngfuncs && (cl.pEngfuncs->GetClientMaxspeed() > 0.0f) && (CVars::sv_maxspeed.GetFloat() > cl.pEngfuncs->GetClientMaxspeed())) vars.Maxspeed = cl.pEngfuncs->GetClientMaxspeed(); // Get true maxspeed in other mods (example: CS 1.6) else vars.Maxspeed = CVars::sv_maxspeed.GetFloat(); - if (is_cstrike || is_czero) { + if (is_cstrike_dir) { vars.BhopcapMultiplier = 0.8f; vars.BhopcapMaxspeedScale = 1.2f; vars.HasStamina = !CVars::bxt_remove_stamina.GetBool(); @@ -6599,7 +6757,7 @@ HLStrafe::MovementVars HwDLL::GetMovementVars() vars.BhopcapMaxspeedScale = 1.7f; } - if (!is_cstrike && !is_czero && !is_tfc) + if (!is_cstrike_dir && !is_tfc_dir) vars.UseSlow = true; if (svs->maxclients >= 1) { diff --git a/BunnymodXT/modules/HwDLL.hpp b/BunnymodXT/modules/HwDLL.hpp index d4fcf699..7e715124 100644 --- a/BunnymodXT/modules/HwDLL.hpp +++ b/BunnymodXT/modules/HwDLL.hpp @@ -346,6 +346,9 @@ class HwDLL : public IHookableNameFilterOrdered int lastRecordedHealth; + bool is_cstrike_dir = false; + bool is_tfc_dir = false; + globalvars_t *ppGlobals; engine_studio_api_t *pEngStudio; engine_api_t *pEngineAPI; @@ -536,6 +539,11 @@ class HwDLL : public IHookableNameFilterOrdered struct Cmd_BXT_CH_CheckPoint_Create; struct Cmd_BXT_CH_CheckPoint_GoTo; struct Cmd_BXT_Enable_Big_Map; + struct Cmd_BXT_CH_CheckPoint_Remove; + struct Cmd_BXT_CH_CheckPoint_Reset; + struct Cmd_BXT_CH_CheckPoint_Next; + struct Cmd_BXT_CH_CheckPoint_Prev; + struct Cmd_BXT_CH_CheckPoint_Current; void RegisterCVarsAndCommandsIfNeeded(); void InsertCommands(); @@ -779,12 +787,18 @@ class HwDLL : public IHookableNameFilterOrdered void ChHookPlayer(); float ch_hook_hp_before; +public: + unsigned int ch_checkpoint_current = 0; + unsigned int ch_checkpoint_total = 0; + protected: bool ch_checkpoint_is_set; - Vector ch_checkpoint_origin; - Vector ch_checkpoint_vel; - Vector ch_checkpoint_viewangles; - bool ch_checkpoint_is_duck; + std::vector ch_checkpoint_origin; + std::vector ch_checkpoint_vel; + std::vector ch_checkpoint_viewangles; + std::vector ch_checkpoint_is_duck; + unsigned long ch_checkpoint_id_goto_specified = 0; + unsigned long ch_checkpoint_id_remove_specified = 0; public: bool is_big_map = false; From 508ce924c7db985840b8c9c16224e505f6f23161 Mon Sep 17 00:00:00 2001 From: SmileyAG Date: Wed, 29 Nov 2023 08:09:59 +0400 Subject: [PATCH 2/6] Changes requested --- BunnymodXT/modules/HwDLL.cpp | 99 +++++++++++++++++++----------------- BunnymodXT/modules/HwDLL.hpp | 2 - 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index d35bd88e..e3033997 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -3322,7 +3322,7 @@ void HwDLL::ChHookPlayer() { struct HwDLL::Cmd_BXT_CH_CheckPoint_Create { - USAGE("Usage: bxt_ch_checkpoint_create\n"); + USAGE("Usage: bxt_ch_checkpoint_create\nCreates the checkpoint.\n"); static void handler() { @@ -3362,22 +3362,27 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo USAGE("Usage: bxt_ch_checkpoint_goto [id]\n Go to the last checkpoint.\n If an id is given, go to the checkpoint with the given id.\n"); static void handler() + { + handler(HwDLL::GetInstance().ch_checkpoint_total); + } + + static void handler(unsigned long id) { auto &hw = HwDLL::GetInstance(); if (!hw.ch_checkpoint_is_set) - { - hw.ch_checkpoint_id_goto_specified = 0; // Reset ID return; - } auto &cl = ClientDLL::GetInstance(); auto pl = hw.GetPlayerEdict(); - if (!pl || hw.ch_checkpoint_is_duck.empty()) + if (!pl) + return; + + if (hw.ch_checkpoint_is_duck.empty()) { - hw.ch_checkpoint_id_goto_specified = 0; // Reset ID + hw.ORIG_Con_Printf("There are no checkpoints!\n"); return; } @@ -3386,13 +3391,13 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo Vector cp_viewangles; bool cp_is_duck; - if ((hw.ch_checkpoint_id_goto_specified > 0) && (hw.ch_checkpoint_is_duck.size() >= hw.ch_checkpoint_id_goto_specified)) // If ID is more than 0 and the size of std::vector is greater than the specified ID, we are fine! + if ((id > 0) && (hw.ch_checkpoint_is_duck.size() >= id)) // If ID is more than 0 and the size of std::vector is not less than the specified ID, we are fine! { - cp_origin = *(hw.ch_checkpoint_origin.begin() + (hw.ch_checkpoint_id_goto_specified - 1)); - cp_vel = *(hw.ch_checkpoint_vel.begin() + (hw.ch_checkpoint_id_goto_specified - 1)); - cp_viewangles = *(hw.ch_checkpoint_viewangles.begin() + (hw.ch_checkpoint_id_goto_specified - 1)); - cp_is_duck = *(hw.ch_checkpoint_is_duck.begin() + (hw.ch_checkpoint_id_goto_specified - 1)); - hw.ch_checkpoint_current = hw.ch_checkpoint_id_goto_specified; + cp_origin = hw.ch_checkpoint_origin[id - 1]; + cp_vel = hw.ch_checkpoint_vel[id - 1]; + cp_viewangles = hw.ch_checkpoint_viewangles[id - 1]; + cp_is_duck = hw.ch_checkpoint_is_duck[id - 1]; + hw.ch_checkpoint_current = id; } else // Otherwise we will use the last element { @@ -3403,8 +3408,6 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo hw.ch_checkpoint_current = hw.ch_checkpoint_total; } - hw.ch_checkpoint_id_goto_specified = 0; // Reset ID - cl.pEngfuncs->SetViewAngles(cp_viewangles); if (cp_is_duck) { @@ -3427,31 +3430,23 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo if (hw.is_cstrike_dir) pl->v.fuser2 = 0; } - - static void handler(unsigned long id) - { - HwDLL::GetInstance().ch_checkpoint_id_goto_specified = id; // Set ID - handler(); - } }; struct HwDLL::Cmd_BXT_CH_CheckPoint_Current { - USAGE("Usage: bxt_ch_checkpoint_current\n"); + USAGE("Usage: bxt_ch_checkpoint_current\nGo to current checkpoint.\n"); static void handler() { auto &hw = HwDLL::GetInstance(); - std::ostringstream ss; - ss << "bxt_ch_checkpoint_goto " << hw.ch_checkpoint_current << "\n"; - hw.ORIG_Cbuf_AddText(ss.str().c_str()); + HwDLL::Cmd_BXT_CH_CheckPoint_GoTo::handler(hw.ch_checkpoint_current); } }; struct HwDLL::Cmd_BXT_CH_CheckPoint_Reset { - USAGE("Usage: bxt_ch_checkpoint_reset\n"); + USAGE("Usage: bxt_ch_checkpoint_reset\nReset the checkpoints.\n"); static void handler() { @@ -3462,6 +3457,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Reset hw.ch_checkpoint_viewangles.clear(); hw.ch_checkpoint_is_duck.clear(); hw.ch_checkpoint_total = hw.ch_checkpoint_current = 0; + hw.ORIG_Con_Printf("Cleared the checkpoints.\n"); } }; @@ -3470,14 +3466,16 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove USAGE("Usage: bxt_ch_checkpoint_remove [id]\n Deletes the last checkpoint.\n If an id is given, deletes the checkpoint with the given id.\n"); static void handler() + { + handler(HwDLL::GetInstance().ch_checkpoint_total); + } + + static void handler(unsigned long id) { auto &hw = HwDLL::GetInstance(); if (!hw.ch_checkpoint_is_duck.empty()) { - int id; - if ((hw.ch_checkpoint_id_remove_specified > 0) && (hw.ch_checkpoint_is_duck.size() >= hw.ch_checkpoint_id_remove_specified)) // If ID is more than 0 and the size of std::vector is greater than the specified ID, we are fine! - id = static_cast(hw.ch_checkpoint_id_remove_specified); - else // Otherwise we will use the last element + if ((id < 1) || (hw.ch_checkpoint_is_duck.size() < id)) // If ID is less than 1 or greater than the size of std::vector, use the last element! id = hw.ch_checkpoint_total; if (hw.ch_checkpoint_current == id) // Is ID equal to the current checkpoint? Well, then decrement both counters! @@ -3494,21 +3492,18 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove hw.ch_checkpoint_vel.erase(hw.ch_checkpoint_vel.begin() + (id - 1)); hw.ch_checkpoint_viewangles.erase(hw.ch_checkpoint_viewangles.begin() + (id - 1)); hw.ch_checkpoint_is_duck.erase(hw.ch_checkpoint_is_duck.begin() + (id - 1)); + hw.ORIG_Con_Printf("Removed the checkpoint with %lu id.\n", id); + } + else + { + hw.ORIG_Con_Printf("There are no checkpoints!\n"); } - - hw.ch_checkpoint_id_remove_specified = 0; // Reset ID - } - - static void handler(unsigned long id) - { - HwDLL::GetInstance().ch_checkpoint_id_remove_specified = id; // Set ID - handler(); } }; struct HwDLL::Cmd_BXT_CH_CheckPoint_Next { - USAGE("Usage: bxt_ch_checkpoint_next\n"); + USAGE("Usage: bxt_ch_checkpoint_next\nGo to the next checkpoint.\n"); static void handler() { @@ -3519,18 +3514,23 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Next if (hw.ch_checkpoint_total > hw.ch_checkpoint_current) // Don't increment if next element is greater than total count { hw.ch_checkpoint_current++; - - std::ostringstream ss; - ss << "bxt_ch_checkpoint_goto " << hw.ch_checkpoint_current << "\n"; - hw.ORIG_Cbuf_AddText(ss.str().c_str()); + HwDLL::Cmd_BXT_CH_CheckPoint_GoTo::handler(hw.ch_checkpoint_current); + } + else + { + hw.ORIG_Con_Printf("Not possible go to the next checkpoint, since the current checkpoint is the last one!\n"); } } + else + { + hw.ORIG_Con_Printf("There are no checkpoints!\n"); + } } }; struct HwDLL::Cmd_BXT_CH_CheckPoint_Prev { - USAGE("Usage: bxt_ch_checkpoint_prev\n"); + USAGE("Usage: bxt_ch_checkpoint_prev\nGo to the previous checkpoint\n"); static void handler() { @@ -3541,11 +3541,16 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Prev if (hw.ch_checkpoint_current > 1) // Don't decrement if we have less than 2 elements { hw.ch_checkpoint_current--; - - std::ostringstream ss; - ss << "bxt_ch_checkpoint_goto " << hw.ch_checkpoint_current << "\n"; - hw.ORIG_Cbuf_AddText(ss.str().c_str()); + HwDLL::Cmd_BXT_CH_CheckPoint_GoTo::handler(hw.ch_checkpoint_current); } + else + { + hw.ORIG_Con_Printf("Not possible go to the previous checkpoint, since there are less than two of them!\n"); + } + } + else + { + hw.ORIG_Con_Printf("There are no checkpoints!\n"); } } }; diff --git a/BunnymodXT/modules/HwDLL.hpp b/BunnymodXT/modules/HwDLL.hpp index 7e715124..890dccc2 100644 --- a/BunnymodXT/modules/HwDLL.hpp +++ b/BunnymodXT/modules/HwDLL.hpp @@ -797,8 +797,6 @@ class HwDLL : public IHookableNameFilterOrdered std::vector ch_checkpoint_vel; std::vector ch_checkpoint_viewangles; std::vector ch_checkpoint_is_duck; - unsigned long ch_checkpoint_id_goto_specified = 0; - unsigned long ch_checkpoint_id_remove_specified = 0; public: bool is_big_map = false; From a7e9168fbf36cf272e600feef3cb74362559354d Mon Sep 17 00:00:00 2001 From: SmileyAG Date: Thu, 30 Nov 2023 04:25:42 +0400 Subject: [PATCH 3/6] Added bxt_ch_checkpoint_remove_after --- BunnymodXT/modules/HwDLL.cpp | 30 ++++++++++++++++++++++++++++++ BunnymodXT/modules/HwDLL.hpp | 1 + 2 files changed, 31 insertions(+) diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index e3033997..3271ddc6 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -3501,6 +3501,35 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove } }; +struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove_After +{ + USAGE("Usage: bxt_ch_checkpoint_remove_after [id]\nDeletes the checkpoints following id.\n"); + + static void handler(unsigned long id) + { + auto &hw = HwDLL::GetInstance(); + if (!hw.ch_checkpoint_is_duck.empty()) + { + if ((id > 0) && (hw.ch_checkpoint_is_duck.size() > id)) // If ID is more than 0 and the size of std::vector is greater than the specified ID, we are fine! + { + if (hw.ch_checkpoint_current > id) // If the current checkpoint has an ID greater than the specified one, then we equate it to the specified one. + hw.ch_checkpoint_current = id; + + hw.ch_checkpoint_origin.erase(hw.ch_checkpoint_origin.begin() + id, hw.ch_checkpoint_origin.end()); + hw.ch_checkpoint_vel.erase(hw.ch_checkpoint_vel.begin() + id, hw.ch_checkpoint_vel.end()); + hw.ch_checkpoint_viewangles.erase(hw.ch_checkpoint_viewangles.begin() + id, hw.ch_checkpoint_viewangles.end()); + hw.ch_checkpoint_is_duck.erase(hw.ch_checkpoint_is_duck.begin() + id, hw.ch_checkpoint_is_duck.end()); + hw.ch_checkpoint_total = id; + hw.ORIG_Con_Printf("Removed the checkpoints following %lu id.\n", id); + } + } + else + { + hw.ORIG_Con_Printf("There are no checkpoints!\n"); + } + } +}; + struct HwDLL::Cmd_BXT_CH_CheckPoint_Next { USAGE("Usage: bxt_ch_checkpoint_next\nGo to the next checkpoint.\n"); @@ -5728,6 +5757,7 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded() wrapper::AddCheat>("bxt_ch_checkpoint_create"); wrapper::AddCheat, Handler>("bxt_ch_checkpoint_goto"); wrapper::AddCheat, Handler>("bxt_ch_checkpoint_remove"); + wrapper::AddCheat>("bxt_ch_checkpoint_remove_after"); wrapper::AddCheat>("bxt_ch_checkpoint_reset"); wrapper::AddCheat>("bxt_ch_checkpoint_next"); wrapper::AddCheat>("bxt_ch_checkpoint_prev"); diff --git a/BunnymodXT/modules/HwDLL.hpp b/BunnymodXT/modules/HwDLL.hpp index 890dccc2..34c02c81 100644 --- a/BunnymodXT/modules/HwDLL.hpp +++ b/BunnymodXT/modules/HwDLL.hpp @@ -540,6 +540,7 @@ class HwDLL : public IHookableNameFilterOrdered struct Cmd_BXT_CH_CheckPoint_GoTo; struct Cmd_BXT_Enable_Big_Map; struct Cmd_BXT_CH_CheckPoint_Remove; + struct Cmd_BXT_CH_CheckPoint_Remove_After; struct Cmd_BXT_CH_CheckPoint_Reset; struct Cmd_BXT_CH_CheckPoint_Next; struct Cmd_BXT_CH_CheckPoint_Prev; From caba62c4766db1991339ac54e560f50304848477 Mon Sep 17 00:00:00 2001 From: SmileyAG Date: Thu, 30 Nov 2023 04:30:38 +0400 Subject: [PATCH 4/6] Enabled velocity and disabled onground check upon HLKZ standards for CPs --- BunnymodXT/cvars.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BunnymodXT/cvars.hpp b/BunnymodXT/cvars.hpp index 1154b193..e7d92843 100644 --- a/BunnymodXT/cvars.hpp +++ b/BunnymodXT/cvars.hpp @@ -233,8 +233,8 @@ X(bxt_splits_start_timer_on_first_split, "0") \ X(bxt_splits_end_on_last_split, "0") \ X(bxt_ch_hook_speed, "869") \ - X(bxt_ch_checkpoint_with_vel, "0") \ - X(bxt_ch_checkpoint_onground_only, "1") + X(bxt_ch_checkpoint_with_vel, "1") \ + X(bxt_ch_checkpoint_onground_only, "0") class CVarWrapper { From f5b2104b8bacebe3345296a789b8789b4099dc06 Mon Sep 17 00:00:00 2001 From: SmileyAG <58108407+SmileyAG@users.noreply.github.com> Date: Fri, 1 Mar 2024 04:45:52 +0400 Subject: [PATCH 5/6] bxt_ch_checkpoint_remove_after: print message in case the ID is invalid --- BunnymodXT/modules/HwDLL.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index 3271ddc6..c3fcdb2c 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -3522,6 +3522,10 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove_After hw.ch_checkpoint_total = id; hw.ORIG_Con_Printf("Removed the checkpoints following %lu id.\n", id); } + else + { + hw.ORIG_Con_Printf("ID is invalid!\n"); + } } else { From 2b855b55fb3cf26b1607352c01285de138a6c621 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 6 Mar 2024 21:22:28 -0800 Subject: [PATCH 6/6] Apply suggestions from code review --- BunnymodXT/modules/HwDLL.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index c3fcdb2c..c83b08a3 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -3322,7 +3322,7 @@ void HwDLL::ChHookPlayer() { struct HwDLL::Cmd_BXT_CH_CheckPoint_Create { - USAGE("Usage: bxt_ch_checkpoint_create\nCreates the checkpoint.\n"); + USAGE("Usage: bxt_ch_checkpoint_create\n Creates the checkpoint.\n"); static void handler() { @@ -3434,7 +3434,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_GoTo struct HwDLL::Cmd_BXT_CH_CheckPoint_Current { - USAGE("Usage: bxt_ch_checkpoint_current\nGo to current checkpoint.\n"); + USAGE("Usage: bxt_ch_checkpoint_current\n Go to current checkpoint.\n"); static void handler() { @@ -3446,7 +3446,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Current struct HwDLL::Cmd_BXT_CH_CheckPoint_Reset { - USAGE("Usage: bxt_ch_checkpoint_reset\nReset the checkpoints.\n"); + USAGE("Usage: bxt_ch_checkpoint_reset\n Reset the checkpoints.\n"); static void handler() { @@ -3503,7 +3503,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove_After { - USAGE("Usage: bxt_ch_checkpoint_remove_after [id]\nDeletes the checkpoints following id.\n"); + USAGE("Usage: bxt_ch_checkpoint_remove_after [id]\n Deletes the checkpoints following id.\n"); static void handler(unsigned long id) { @@ -3536,7 +3536,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Remove_After struct HwDLL::Cmd_BXT_CH_CheckPoint_Next { - USAGE("Usage: bxt_ch_checkpoint_next\nGo to the next checkpoint.\n"); + USAGE("Usage: bxt_ch_checkpoint_next\n Go to the next checkpoint.\n"); static void handler() { @@ -3563,7 +3563,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Next struct HwDLL::Cmd_BXT_CH_CheckPoint_Prev { - USAGE("Usage: bxt_ch_checkpoint_prev\nGo to the previous checkpoint\n"); + USAGE("Usage: bxt_ch_checkpoint_prev\n Go to the previous checkpoint\n"); static void handler() { @@ -3578,7 +3578,7 @@ struct HwDLL::Cmd_BXT_CH_CheckPoint_Prev } else { - hw.ORIG_Con_Printf("Not possible go to the previous checkpoint, since there are less than two of them!\n"); + hw.ORIG_Con_Printf("Not possible go to the previous checkpoint, since the current checkpoint is the first one!\n"); } } else