From 2028a2886b6bc7634e16d29c845ff45dd3163979 Mon Sep 17 00:00:00 2001
From: explorer <explorer@explorer.explorer>
Date: Fri, 18 Oct 2024 01:46:40 +0300
Subject: [PATCH] bug fixes, logic fixes

---
 Copy_Command.hpp        | 105 +++++++++++++++-------------------------
 Estimate_Velocity.hpp   |   2 +-
 Perform_Shove_Trace.hpp |   2 +-
 Spawn_Grenade.hpp       |  12 ++---
 4 files changed, 46 insertions(+), 75 deletions(-)

diff --git a/Copy_Command.hpp b/Copy_Command.hpp
index 3490590..ebcc081 100644
--- a/Copy_Command.hpp
+++ b/Copy_Command.hpp
@@ -179,18 +179,11 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
 		{
 			if (Extra_Commands < 1)
 			{
-				if (Reserve == 0)
-				{
-					*(__int32*)((unsigned __int32)Network_Channel + 8) += 150;
-				}
-				else
-				{
-					__int32 Sequence_Shift = (*(__int32*)((unsigned __int32)Local_Player + 5324) + ~- 150) / 150 * 150 + (Reserve * 150);
+				__int32 Sequence_Shift = (*(__int32*)((unsigned __int32)Local_Player + 5324) + ~-150) / 150 * 150 + (Reserve * 150);
 
-					if (Sequence_Shift > 0)
-					{
-						*(__int32*)((unsigned __int32)Network_Channel + 8) += Sequence_Shift;
-					}
+				if (Sequence_Shift > 0)
+				{
+					*(__int32*)((unsigned __int32)Network_Channel + 8) += Sequence_Shift;
 				}
 			}
 
@@ -363,10 +356,10 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
 
 								__int8 Is_Melee = *(__int32*)((unsigned __int32)Weapon_Data + 352) * (*(__int32*)((unsigned __int32)Weapon_Data + 348) ^ 1) <= 1;
 
-								__int8 Healing = (*(__int32*)((unsigned __int32)Local_Player + 7080) == 1) + (*(void**)((unsigned __int32)Local_Player + 8076) != INVALID_HANDLE_VALUE);
-
 								__int8 Reloading = *(__int8*)((unsigned __int32)Weapon + 2493);
 
+								__int32 Healing = (*(__int32*)((unsigned __int32)Local_Player + 7080) == 1) + (*(void**)((unsigned __int32)Local_Player + 8076) != INVALID_HANDLE_VALUE);
+
 								__int32 Weapon_Identifier = Get_Identifier(Weapon, 1, 0);
 
 								__int8 Is_Cold_Melee = Weapon_Identifier == 231;
@@ -389,7 +382,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
 
 										__int8 Forced = 0;
 
-										if (Is_Melee + Healing + Reloading != 0)
+										if ((Is_Melee + Reloading) * (Healing ^ 1) != 0)
 										{
 											if ((Target->Identifier ^ 72) % 348 >= 72)
 											{
@@ -405,7 +398,9 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
 											{
 												__int8 Infected = (Target->Identifier == 264) * (Forced ^ 1);
 
-												if ((Infected ^ 1) + (*(__int32*)((unsigned __int32)Target->Self + 52) == 15) != 0)
+												__int32 Gender = *(__int32*)((unsigned __int32)Target->Self + 52);
+
+												if ((Infected ^ 1) + (Gender == 15) != 0)
 												{
 													using Get_Sequence_Name_Type = char*(__thiscall*)(void* Entity, __int32 Sequence);
 
@@ -442,33 +437,37 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
 
 														if (Perform_Trace_Damage == 1)
 														{
-															Command->Tick_Number = Target->Tick_Number;
-
-															Command->Angles[0] = __builtin_atan2f(-Direction[2], __builtin_hypotf(Direction[0], Direction[1])) * 180 / 3.1415927f;
-
-															Command->Angles[1] = __builtin_atan2f(Direction[1], Direction[0]) * 180 / 3.1415927f;
-
-															if (Cancelable_Shove == 1)
+															if (Healing == 0)
 															{
-																float Shove_Multiplier = min((Global_Variables->Current_Time - *(float*)((unsigned __int32)Weapon + 2704) + *(float*)((unsigned __int32)Weapon + 2700)) / *(float*)((unsigned __int32)Weapon + 2700), 1.f);
+																Command->Tick_Number = Target->Tick_Number;
 
-																Command->Angles[1] += -45 * Shove_Multiplier + 45 * (1 - Shove_Multiplier);
-															}
-															else
-															{
-																Command->Angles[1] += 45;
+																Command->Angles[0] = __builtin_atan2f(-Direction[2], __builtin_hypotf(Direction[0], Direction[1])) * 180 / 3.1415927f;
+
+																Command->Angles[1] = __builtin_atan2f(Direction[1], Direction[0]) * 180 / 3.1415927f;
+
+																if (Cancelable_Shove == 1)
+																{
+																	float Shove_Multiplier = min((Global_Variables->Current_Time - *(float*)((unsigned __int32)Weapon + 2704) + *(float*)((unsigned __int32)Weapon + 2700)) / *(float*)((unsigned __int32)Weapon + 2700), 1.f);
+
+																	Command->Angles[1] += -45 * Shove_Multiplier + 45 * (1 - Shove_Multiplier);
+																}
+																else
+																{
+																	Command->Angles[1] += 45;
+																}
+
+																Command->Buttons |= 2048;
+
+																Block_Buttons = 1;
+
+																Cancelable_Shove = (Gender * Interface_Riot_Deprioritize.Integer * (Forced ^ 1)) == 15;
+
+																*(float*)((unsigned __int32)Target->Self + 16) = Get_Target_Time(Target);
+
+																goto Shove_Found_Target_Label;
 															}
 
-															Command->Buttons |= 2048;
-
-															Block_Buttons = 1;
-
-															if (Interface_Riot_Deprioritize.Integer == 1)
-															{
-																Cancelable_Shove = Infected * 2;
-															}
-
-															*(float*)((unsigned __int32)Target->Self + 16) = Get_Target_Time(Target);
+															Cancelable_Shove = 0;
 
 															goto Shove_Found_Target_Label;
 														}
@@ -492,7 +491,7 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
 								{
 									__int8 Can_Attack = (*(float*)((unsigned __int32)Weapon + 2400) <= Global_Variables->Current_Time) * (*(__int32*)((unsigned __int32)Weapon + 2436) > 0 - Is_Melee * 2) * (*(float*)((unsigned __int32)Local_Player + 3872) <= Global_Variables->Current_Time);
 
-									if (Healing + (Can_Attack ^ 1) + (Weapon_Identifier == 96) == 0)
+									if ((Weapon_Identifier == 96) + (Can_Attack ^ 1) == 0)
 									{
 										Target_Structure* Aim_Target = nullptr;
 
@@ -700,34 +699,6 @@ void __thiscall Redirected_Copy_Command(void* Unknown_Parameter, Command_Structu
 												}
 											}
 										}
-										else
-										{
-											if (Weapon_Identifier == 73)
-											{										
-												//ideally 150 commands should always be buffered beforehand
-												//at worst buffer them right before slot* command
-												//current solution without buffering takes (interval_per_tick*150) seconds to prepare itself
-												//reason why i'm not doing that now is because it'll take time to redesign prediction code to function properly
-												//specifically:
-												//ignoring network time updates for good period of time isn't good idea
-												//viewmodel animations will jitter at moment of centering around network time 
-												//so is interpolation
-												//besides all that, it'll invoke clock correction on server's side and that's pretty unstable (especially on ~100 tickrate)
-													
-												Global_Variables->Current_Time -= Global_Variables->Interval_Per_Tick * 150;
-
-												//leaving other ones of sanity for later
-												if (*(float*)((unsigned __int32)Weapon + 2400) <= Global_Variables->Current_Time)
-												{
-													if ((Command->Buttons & 2049) != 0)
-													{
-														Sequence_Shift(0);
-
-														Block_Buttons = 1;
-													}
-												}
-											}
-										}
 
 										if ((Command->Buttons & 1) == 1)
 										{
diff --git a/Estimate_Velocity.hpp b/Estimate_Velocity.hpp
index e9599ea..c5556de 100755
--- a/Estimate_Velocity.hpp
+++ b/Estimate_Velocity.hpp
@@ -50,7 +50,7 @@ __int32 Get_Identifier(void* Entity, __int8 Raw, __int8 Equipment)
 		{
 			if (*(__int8*)((unsigned __int32)Entity + 221) == 0)
 			{
-				if (*(__int32*)((unsigned __int32)Entity + 572) == 131088)
+				if ((*(__int32*)((unsigned __int32)Entity + 572) - 131088 & 255) == 0)
 				{
 					using Get_Sequence_Name_Type = char*(__thiscall*)(void* Entity, __int32 Sequence);
 
diff --git a/Perform_Shove_Trace.hpp b/Perform_Shove_Trace.hpp
index a74e3df..85c79f6 100755
--- a/Perform_Shove_Trace.hpp
+++ b/Perform_Shove_Trace.hpp
@@ -1,6 +1,6 @@
 void __thiscall Perform_Shove_Trace(void* Stack)
 {
-	void* Entity = *(void**)((unsigned __int32)Stack - 276);
+	void* Entity = *(void**)((unsigned __int32)Stack + 332);
 
 	if (Entity == Perform_Trace_Target)
 	{
diff --git a/Spawn_Grenade.hpp b/Spawn_Grenade.hpp
index 74555a8..35b1b27 100755
--- a/Spawn_Grenade.hpp
+++ b/Spawn_Grenade.hpp
@@ -6,20 +6,20 @@ void __thiscall Redirected_Spawn_Grenade(void* Entity)
 
 	float Minimum[3] =
 	{
-		-16,
+		-16.f,
 		
-		-16,
+		-16.f,
 		
-		-16
+		-16.f
 	};
 
 	float Maximum[3] =
 	{ 
-		16,
+		16.f,
 
-		16,
+		16.f,
 
-		16
+		16.f
 	};
 
 	Set_Size_Type((unsigned __int32)Client_Module + 281664)(Entity, Minimum, Maximum);