├── .gitignore ├── .gitmodules ├── README.md ├── css.sln └── src ├── DllMain.cpp ├── EndScene.cpp ├── Interfaces.cpp ├── Interfaces.h ├── Menu.cpp ├── Menu.h ├── SDK ├── CBaseClientState.h ├── CBaseEntity.h ├── CInput.h ├── CRC.cpp ├── CRC.h ├── Color.h ├── Convar.cpp ├── Convar.h ├── IAppSystem.h ├── IBaseClientDll.h ├── ICVar.h ├── IClientEntity.h ├── IClientEntityList.h ├── IConVar.h ├── IEngineTrace.cpp ├── IEngineTrace.h ├── IGameMovement.h ├── ISurface.h ├── IVEngineClient.h ├── IVModelInfo.h ├── SDK.h ├── UtlBuffer.cpp ├── UtlBuffer.h ├── UtlMemory.h ├── UtlString.cpp ├── UtlString.h ├── UtlVector.h ├── VMatrix.cpp ├── VMatrix.h ├── Vector.cpp ├── Vector.h ├── Vector2D.cpp ├── Vector2D.h ├── Vector4D.cpp ├── Vector4D.h ├── bspflags.h ├── characterset.cpp ├── characterset.h ├── cmodel.h ├── definitions.h ├── gametrace.h ├── globalvars_base.h ├── imovehelper.h ├── iprediction.h ├── player_info.h ├── studio.h ├── trace.h ├── vcollide.h └── vphysics_interface.h ├── css.vcxproj ├── css.vcxproj.filters ├── hacks ├── aimbot.cpp ├── aimbot.h ├── misc.cpp ├── misc.h ├── visuals.cpp └── visuals.h ├── hooks ├── CreateMove.cpp ├── EndScene.cpp ├── FrameStageNotify.cpp ├── GetUserCmd.cpp ├── Paint.cpp ├── Reset.cpp ├── WndProc.cpp ├── WriteUsercmdDeltaToBuffer.cpp ├── hooks.cpp └── hooks.h ├── sdk ├── CGlobalVars.h ├── IVDebugOverlay.h ├── checksum_md5.cpp └── checksum_md5.h └── tools ├── config.cpp ├── config.h ├── entity.cpp ├── entity.h ├── fnv_hash.h ├── game.cpp ├── game.h ├── math.cpp ├── math.h ├── netvar_manager.cpp ├── netvar_manager.h ├── tools.cpp ├── tools.h ├── virtuals.h └── vmt_hook.h /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # DNX 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | *.opendb 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opensdf 79 | *.sdf 80 | *.db 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | 88 | # TFS 2012 Local Workspace 89 | $tf/ 90 | 91 | # Guidance Automation Toolkit 92 | *.gpState 93 | 94 | # ReSharper is a .NET coding add-in 95 | _ReSharper*/ 96 | *.[Rr]e[Ss]harper 97 | *.DotSettings.user 98 | 99 | # JustCode is a .NET coding add-in 100 | .JustCode 101 | 102 | # TeamCity is a build add-in 103 | _TeamCity* 104 | 105 | # DotCover is a Code Coverage Tool 106 | *.dotCover 107 | 108 | # NCrunch 109 | _NCrunch_* 110 | .*crunch*.local.xml 111 | 112 | # MightyMoose 113 | *.mm.* 114 | AutoTest.Net/ 115 | 116 | # Web workbench (sass) 117 | .sass-cache/ 118 | 119 | # Installshield output folder 120 | [Ee]xpress/ 121 | 122 | # DocProject is a documentation generator add-in 123 | DocProject/buildhelp/ 124 | DocProject/Help/*.HxT 125 | DocProject/Help/*.HxC 126 | DocProject/Help/*.hhc 127 | DocProject/Help/*.hhk 128 | DocProject/Help/*.hhp 129 | DocProject/Help/Html2 130 | DocProject/Help/html 131 | 132 | # Click-Once directory 133 | publish/ 134 | 135 | # Publish Web Output 136 | *.[Pp]ublish.xml 137 | *.azurePubxml 138 | ## TODO: Comment the next line if you want to checkin your 139 | ## web deploy settings but do note that will include unencrypted 140 | ## passwords 141 | #*.pubxml 142 | 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | 154 | # Windows Azure Build Output 155 | csx/ 156 | *.build.csdef 157 | 158 | # Windows Store app package directory 159 | AppPackages/ 160 | 161 | # Visual Studio cache files 162 | # files ending in .cache can be ignored 163 | *.[Cc]ache 164 | # but keep track of directories ending in .cache 165 | !*.[Cc]ache/ 166 | 167 | # Others 168 | ClientBin/ 169 | [Ss]tyle[Cc]op.* 170 | ~$* 171 | *~ 172 | *.dbmdl 173 | *.dbproj.schemaview 174 | *.pfx 175 | *.publishsettings 176 | node_modules/ 177 | orleans.codegen.cs 178 | 179 | # RIA/Silverlight projects 180 | Generated_Code/ 181 | 182 | # Backup & report files from converting an old project file 183 | # to a newer Visual Studio version. Backup files are not needed, 184 | # because we have git ;-) 185 | _UpgradeReport_Files/ 186 | Backup*/ 187 | UpgradeLog*.XML 188 | UpgradeLog*.htm 189 | 190 | # SQL Server files 191 | *.mdf 192 | *.ldf 193 | 194 | # Business Intelligence projects 195 | *.rdl.data 196 | *.bim.layout 197 | *.bim_*.settings 198 | 199 | # Microsoft Fakes 200 | FakesAssemblies/ 201 | 202 | # Node.js Tools for Visual Studio 203 | .ntvs_analysis.dat 204 | 205 | # Visual Studio 6 build log 206 | *.plg 207 | 208 | # Visual Studio 6 workspace options file 209 | *.opt 210 | 211 | # LightSwitch generated files 212 | GeneratedArtifacts/ 213 | _Pvt_Extensions/ 214 | ModelManifest.xml 215 | 216 | Release/ 217 | Debug/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/imgui"] 2 | path = deps/imgui 3 | url = https://github.com/ocornut/imgui 4 | [submodule "deps/json"] 5 | path = deps/json 6 | url = https://github.com/nlohmann/json -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CSS-Internal 2 | 3 | Simple internal multihack for Counter-Strike: Source -------------------------------------------------------------------------------- /css.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2010 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "css", "src\css.vcxproj", "{8BDE8A38-4D30-4501-9809-79971911C1CD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8BDE8A38-4D30-4501-9809-79971911C1CD}.Debug|x86.ActiveCfg = Debug|Win32 15 | {8BDE8A38-4D30-4501-9809-79971911C1CD}.Debug|x86.Build.0 = Debug|Win32 16 | {8BDE8A38-4D30-4501-9809-79971911C1CD}.Release|x86.ActiveCfg = Release|Win32 17 | {8BDE8A38-4D30-4501-9809-79971911C1CD}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {F4A61A8C-817F-425C-AFD5-B0629B92B0DD} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /src/DllMain.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks/hooks.h" 2 | #include 3 | #include 4 | 5 | #define DUMP_CLASS_IDS 6 | 7 | DWORD WINAPI thread(LPVOID dll) 8 | { 9 | AllocConsole(); 10 | freopen("CON", "w", stdout); 11 | SetConsoleTitle("css"); 12 | 13 | initialize_interfaces(); 14 | initialize_hooks(); 15 | 16 | g_cvar->ConsoleColorPrintf(Color(150, 255, 150), "Sucessfully Injected!\n"); 17 | 18 | #ifdef DUMP_CLASS_IDS 19 | std::ofstream file("class_ids.txt"); 20 | file << "enum class EClassIds : int" << std::endl; 21 | file << "{" << std::endl; 22 | auto clazz = g_client->GetAllClasses(); 23 | while (clazz) 24 | { 25 | file << "\t" << clazz->m_pNetworkName << " = " << clazz->m_ClassID << "," << std::endl; 26 | clazz = clazz->m_pNext; 27 | } 28 | 29 | file << "};" << std::endl; 30 | file.close(); 31 | #endif 32 | 33 | while (!(GetAsyncKeyState(VK_END) & 0x8000)) 34 | { 35 | Sleep(100); 36 | } 37 | 38 | FreeConsole(); 39 | uninitialize_hooks(); 40 | Sleep(1000); 41 | g_cvar->ConsoleColorPrintf(Color(255, 50, 50), "Sucessfully Unloaded!\n"); 42 | FreeLibraryAndExitThread(static_cast(dll), EXIT_SUCCESS); 43 | } 44 | 45 | BOOL WINAPI DllMain( 46 | _In_ HINSTANCE hinstDLL, 47 | _In_ DWORD fdwReason, 48 | _In_ LPVOID lpvReserved 49 | ) 50 | { 51 | if (fdwReason == DLL_PROCESS_ATTACH) 52 | { 53 | if (hinstDLL) 54 | DisableThreadLibraryCalls(hinstDLL); 55 | CreateThread(nullptr, 0, thread, hinstDLL, 0, nullptr); 56 | } 57 | 58 | return TRUE; 59 | } -------------------------------------------------------------------------------- /src/EndScene.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "Settings.h" 3 | #include "SDK\CBaseEntity.h" 4 | #include "Visuals.h" 5 | #include "Menu.h" 6 | 7 | void Initialize_GUI(IDirect3DDevice9* vDevice) 8 | { 9 | ImGui_ImplDX9_Init(hWindow, vDevice); 10 | 11 | auto& style = ImGui::GetStyle(); 12 | 13 | style.ChildWindowRounding = 3.f; 14 | style.GrabRounding = 0.f; 15 | style.WindowRounding = 0.f; 16 | style.ScrollbarRounding = 3.f; 17 | style.FrameRounding = 3.f; 18 | style.WindowTitleAlign = ImVec2(0.5f, 0.5f); 19 | 20 | style.Colors[ImGuiCol_Text] = ImVec4(0.73f, 0.73f, 0.73f, 1.00f); 21 | style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); 22 | style.Colors[ImGuiCol_WindowBg] = ImVec4(0.26f, 0.26f, 0.26f, 0.95f); 23 | style.Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.28f, 0.28f, 0.28f, 1.00f); 24 | style.Colors[ImGuiCol_PopupBg] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f); 25 | style.Colors[ImGuiCol_Border] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f); 26 | style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f); 27 | style.Colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); 28 | style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); 29 | style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); 30 | style.Colors[ImGuiCol_TitleBg] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 31 | style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 32 | style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 33 | style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f); 34 | style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.21f, 0.21f, 0.21f, 1.00f); 35 | style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 36 | style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 37 | style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 38 | style.Colors[ImGuiCol_ComboBg] = ImVec4(0.32f, 0.32f, 0.32f, 1.00f); 39 | style.Colors[ImGuiCol_CheckMark] = ImVec4(0.78f, 0.78f, 0.78f, 1.00f); 40 | style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.74f, 0.74f, 0.74f, 1.00f); 41 | style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.74f, 0.74f, 0.74f, 1.00f); 42 | style.Colors[ImGuiCol_Button] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 43 | style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.43f, 0.43f, 0.43f, 1.00f); 44 | style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); 45 | style.Colors[ImGuiCol_Header] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 46 | style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 47 | style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 48 | style.Colors[ImGuiCol_Column] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); 49 | style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); 50 | style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); 51 | style.Colors[ImGuiCol_ResizeGrip] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 52 | style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); 53 | style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); 54 | style.Colors[ImGuiCol_CloseButton] = ImVec4(0.59f, 0.59f, 0.59f, 1.00f); 55 | style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); 56 | style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); 57 | style.Colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); 58 | style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); 59 | style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); 60 | style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); 61 | style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.32f, 0.52f, 0.65f, 1.00f); 62 | style.Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.50f); 63 | 64 | DrawManager = std::make_unique(vDevice); 65 | DrawManager->CreateObjects(); 66 | } 67 | 68 | HRESULT STDMETHODCALLTYPE EndScene_Hooked(IDirect3DDevice9* vDevice) 69 | { 70 | if (bWasInitialized) 71 | { 72 | ImGui::GetIO().MouseDrawCursor = Settings::Menu::Opened; 73 | ImGui_ImplDX9_NewFrame(); 74 | 75 | Menu::EndScene(); 76 | 77 | DrawManager->BeginRendering(); 78 | 79 | Visuals::EndScene(); 80 | 81 | ImGui::Render(); 82 | 83 | DrawManager->EndRendering(); 84 | } 85 | else 86 | { 87 | Initialize_GUI(vDevice); 88 | bWasInitialized = true; 89 | } 90 | 91 | return oEndScene(vDevice); 92 | } -------------------------------------------------------------------------------- /src/Interfaces.cpp: -------------------------------------------------------------------------------- 1 | #include "interfaces.h" 2 | #include "tools/tools.h" 3 | 4 | //------------------------------------------// 5 | // CreateInterface 6 | //------------------------------------------// 7 | IBaseClientDll* g_client = nullptr; 8 | IClientEntityList* g_entitylist = nullptr; 9 | IGameMovement* g_gamemovement = nullptr; 10 | IPrediction* g_prediction = nullptr; 11 | IVEngineClient* g_engine = nullptr; 12 | IVModelInfo* g_modelinfo = nullptr; 13 | IEngineTrace* g_trace = nullptr; 14 | IVDebugOverlay* g_debugoverlay = nullptr; 15 | ICvar* g_cvar = nullptr; 16 | IPhysicsSurfaceProps* g_physprops = nullptr; 17 | CEngineVGui* g_enginevgui = nullptr; 18 | ISurface* g_surface = nullptr; 19 | //------------------------------------------// 20 | // Pattern Scan 21 | //------------------------------------------// 22 | CInput* g_input = nullptr; 23 | CBaseClientState* g_clientstate = nullptr; 24 | IDirect3DDevice9* g_d3ddevice = nullptr; 25 | CGlobalVars* g_globals = nullptr; 26 | IMoveHelper* g_movehelper = nullptr; 27 | //------------------------------------------// 28 | // Initialize Interfaces 29 | //------------------------------------------// 30 | void initialize_interfaces() 31 | { 32 | //------------------------------------------// 33 | // Factories 34 | //------------------------------------------// 35 | auto client_factory = reinterpret_cast(GetProcAddress(GetModuleHandleA("client.dll"), "CreateInterface")); 36 | auto engine_factory = reinterpret_cast(GetProcAddress(GetModuleHandleA("engine.dll"), "CreateInterface")); 37 | auto vstdlib_factory = reinterpret_cast(GetProcAddress(GetModuleHandleA("vstdlib.dll"), "CreateInterface")); 38 | auto vphysics_factory = reinterpret_cast(GetProcAddress(GetModuleHandleA("vphysics.dll"), "CreateInterface")); 39 | auto vguimatsurface_factory = reinterpret_cast(GetProcAddress(GetModuleHandleA("vguimatsurface.dll"), "CreateInterface")); 40 | //------------------------------------------// 41 | // CreateInterface 42 | //------------------------------------------// 43 | g_client = reinterpret_cast(client_factory("VClient017", nullptr)); 44 | g_entitylist = reinterpret_cast(client_factory("VClientEntityList003", nullptr)); 45 | g_gamemovement = reinterpret_cast(client_factory("GameMovement001", nullptr)); 46 | g_prediction = reinterpret_cast(client_factory("VClientPrediction001", nullptr)); 47 | g_engine = reinterpret_cast(engine_factory("VEngineClient014", nullptr)); 48 | g_modelinfo = reinterpret_cast(engine_factory("VModelInfoClient006", nullptr)); 49 | g_trace = reinterpret_cast(engine_factory("EngineTraceClient003", nullptr)); 50 | g_debugoverlay = reinterpret_cast(engine_factory("VDebugOverlay003", nullptr)); 51 | g_cvar = reinterpret_cast(vstdlib_factory("VEngineCvar004", nullptr)); 52 | g_physprops = reinterpret_cast(vphysics_factory("VPhysicsSurfaceProps001", nullptr)); 53 | g_enginevgui = reinterpret_cast(engine_factory("VEngineVGui001", nullptr)); 54 | g_surface = reinterpret_cast(vguimatsurface_factory("VGUI_Surface030", nullptr)); 55 | //------------------------------------------// 56 | // Pattern Scan 57 | //------------------------------------------// 58 | g_input = **reinterpret_cast( 59 | tools::find_pattern("client.dll", "8B 0D ? ? ? ? 8B 01 FF 60 44") + 2); 60 | g_clientstate = *reinterpret_cast( 61 | tools::find_pattern("engine.dll", "83 3D ? ? ? ? ? B8 ? ? ? ? B9 ? ? ? ? 0F 4D C1") + 2); 62 | g_d3ddevice = **reinterpret_cast( 63 | tools::find_pattern("shaderapidx9.dll", "A1 ? ? ? ? 8D 53 08") + 1); 64 | g_globals = **reinterpret_cast(( 65 | *reinterpret_cast(g_client))[0] + 0x34); 66 | g_movehelper = **reinterpret_cast( 67 | tools::find_pattern("client.dll", "FF 35 ? ? ? ? 50 8B 11 56") + 2); 68 | } -------------------------------------------------------------------------------- /src/Interfaces.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sdk/sdk.h" 4 | #include 5 | #include 6 | 7 | //------------------------------------------// 8 | // CreateInterface 9 | //------------------------------------------// 10 | extern IBaseClientDll* g_client; 11 | extern IClientEntityList* g_entitylist; 12 | extern IGameMovement* g_gamemovement; 13 | extern IPrediction* g_prediction; 14 | extern IVEngineClient* g_engine; 15 | extern IVModelInfo* g_modelinfo; 16 | extern IEngineTrace* g_trace; 17 | extern IVDebugOverlay* g_debugoverlay; 18 | extern ICvar* g_cvar; 19 | extern IPhysicsSurfaceProps* g_physprops; 20 | extern CEngineVGui* g_enginevgui; 21 | extern ISurface* g_surface; 22 | //------------------------------------------// 23 | // Pattern Scan 24 | //------------------------------------------// 25 | extern CInput* g_input; 26 | extern CBaseClientState* g_clientstate; 27 | extern IDirect3DDevice9* g_d3ddevice; 28 | extern CGlobalVars* g_globals; 29 | extern IMoveHelper* g_movehelper; 30 | //------------------------------------------// 31 | // Initialize Interfaces 32 | //------------------------------------------// 33 | extern void initialize_interfaces(); -------------------------------------------------------------------------------- /src/Menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class cmenu 4 | { 5 | public: 6 | void render(); 7 | 8 | private: 9 | enum class tabs_e 10 | { 11 | Aimbot, 12 | Visuals, 13 | Misc, 14 | Colors, 15 | Configs, 16 | Players 17 | }; 18 | 19 | void aimbot_tab(); 20 | void visuals_tab(); 21 | void misc_tab(); 22 | void colors_tab(); 23 | void configs_tab(); 24 | void players_tab(); 25 | 26 | tabs_e m_tab_selected = tabs_e::Aimbot; 27 | }; 28 | 29 | extern cmenu* menu; -------------------------------------------------------------------------------- /src/SDK/CBaseClientState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CBaseClientState 4 | { 5 | public: 6 | char pad_0x0000[0xC]; //0x0000 7 | float m_flConnectTime; //0x000C 8 | __int32 m_nRetryNumber; //0x0010 9 | char pad_0x0014[0x4]; //0x0014 10 | __int32 N00000007; //0x0018 11 | char pad_0x001C[0x4]; //0x001C 12 | __int32 N00000009; //0x0020 13 | char pad_0x0024[0x40]; //0x0024 14 | __int32 m_nCurrentSequence; //0x0064 15 | char pad_0x0068[0x8]; //0x0068 16 | __int32 m_nDeltaTick; //0x0070 17 | __int32 m_bPaused; //0x0074 18 | __int32 m_nViewEntity; //0x0078 19 | __int32 m_nPlayerSlot; //0x007C 20 | char m_szLevelName[40]; //0xB37888 21 | char pad_0x00A8[0x57]; //0x00A8 22 | char m_szLevelNameShort[40]; //0xB37888 23 | char pad_0x0127[0x59]; //0x0127 24 | __int32 m_nMaxClients; //0x0180 25 | char pad_0x0184[0x55C]; //0x0184 26 | 27 | }; //Size=0x06E0 -------------------------------------------------------------------------------- /src/SDK/CBaseEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SDK.h" 4 | #include "../tools/netvar_manager.h" 5 | #include "../tools/virtuals.h" 6 | #include "../tools/tools.h" 7 | 8 | class C_BaseCombatWeapon; 9 | class C_BaseEntity : public IClientEntity 10 | { 11 | public: 12 | NETVAR(get_team_num, "CBaseEntity", "m_iTeamNum", std::int32_t); 13 | NETVAR(get_origin, "CBaseEntity", "m_vecOrigin", Vector); 14 | 15 | void SetAbsOrigin(const Vector& a2) 16 | { 17 | static auto set_abs_origin = reinterpret_cast( 18 | tools::find_pattern("client.dll", "55 8B EC 56 57 8B F1 E8 ? ? ? ? 8B 7D 08")); 19 | set_abs_origin(this, a2); 20 | } 21 | }; 22 | 23 | class C_BaseAnimating : public C_BaseEntity 24 | { 25 | public: 26 | NETVAR(get_hitbox_set, "CBaseAnimating", "m_nHitboxSet", std::uint32_t); 27 | }; 28 | 29 | class C_BasePlayer : public C_BaseAnimating 30 | { 31 | public: 32 | NETVAR(get_life_state, "CBasePlayer", "m_lifeState", std::uint8_t); 33 | NETVAR(get_health, "CBasePlayer", "m_iHealth", std::int32_t); 34 | NETVAR(get_flags, "CBasePlayer", "m_fFlags", std::int32_t); 35 | NETVAR(get_tick_base, "CBasePlayer", "m_nTickBase", std::uint32_t); 36 | NETVAR(get_aim_punch, "CBasePlayer", "m_vecPunchAngle", Vector); 37 | NETVAR(get_view_offset, "CBasePlayer", "m_vecViewOffset[0]", Vector); 38 | NETVAR(get_next_attack, "CBaseCombatCharacter", "m_flNextAttack", float); 39 | 40 | C_BaseCombatWeapon* GetActiveWeapon() 41 | { 42 | return get_vfunc(this, 222)(this); 43 | } 44 | 45 | void SetLocalViewAngles(const QAngle &viewAngles) 46 | { 47 | get_vfunc(this, 293)(this, viewAngles); 48 | } 49 | 50 | const Vector& WorldSpaceCenter() 51 | { 52 | return get_vfunc(this, 66)(this); 53 | } 54 | 55 | Vector get_eye_position() 56 | { 57 | return get_origin() + get_view_offset(); 58 | } 59 | 60 | void UpdateButtonState(int nUserCmdButtonMask) 61 | { 62 | static auto function = reinterpret_cast( 63 | tools::get_rel32(tools::find_pattern("client.dll", "E8 ? ? ? ? 8B 17 8D 43 0C"), 1, 5)); 64 | function(this, nUserCmdButtonMask); 65 | } 66 | }; 67 | 68 | class C_CSPlayer : public C_BasePlayer 69 | { 70 | public: 71 | NETVAR(get_eye_angles, "CCSPlayer", "m_angEyeAngles[0]", Vector); 72 | NETVAR(get_armor_value, "CCSPlayer", "m_ArmorValue", int); 73 | NETVAR(get_has_helmet, "CCSPlayer", "m_bHasHelmet", bool); 74 | NETVAR(get_flash_max_alpha, "CCSPlayer", "m_flFlashMaxAlpha", float); 75 | }; 76 | 77 | #define MAX_WEAPON_STRING 80 78 | #define MAX_WEAPON_PREFIX 16 79 | #define MAX_WEAPON_AMMO_NAME 32 80 | 81 | typedef enum { 82 | EMPTY, 83 | SINGLE, 84 | SINGLE_NPC, 85 | WPN_DOUBLE, // Can't be "DOUBLE" because windows.h uses it. 86 | DOUBLE_NPC, 87 | BURST, 88 | RELOAD, 89 | RELOAD_NPC, 90 | MELEE_MISS, 91 | MELEE_HIT, 92 | MELEE_HIT_WORLD, 93 | SPECIAL1, 94 | SPECIAL2, 95 | SPECIAL3, 96 | TAUNT, 97 | DEPLOY, 98 | 99 | // Add new shoot sound types here 100 | 101 | NUM_SHOOT_SOUND_TYPES, 102 | } WeaponSound_t; 103 | 104 | class CHudTexture; 105 | 106 | #pragma pack (push, 1) 107 | 108 | class CCSWeaponInfo 109 | { 110 | public: 111 | virtual void Parse(KeyValues*, const char*) = 0; 112 | 113 | bool bParsedScript; //0x0004 114 | bool bLoadedHudElements; //0x0005 115 | char szClassName[MAX_WEAPON_STRING]; //0x0006 116 | char szPrintName[MAX_WEAPON_STRING]; //0x0056 117 | char szViewModel[MAX_WEAPON_STRING]; //0x00A6 118 | char szWorldModel[MAX_WEAPON_STRING]; //0x00F6 119 | char szAnimationPrefix[MAX_WEAPON_PREFIX]; //0x0146 120 | char pad_0156[2]; //0x0156 121 | int32_t iSlot; //0x0158 122 | int32_t iPosition; //0x015C 123 | int32_t iMaxClip1; //0x0160 124 | int32_t iMaxClip2; //0x0164 125 | int32_t iDefaultClip1; //0x0168 126 | int32_t iDefaultClip2; //0x016C 127 | int32_t iWeight; //0x0170 128 | int32_t iRumbleEffect; //0x0174 129 | bool bAutoSwitchTo; //0x0178 130 | bool bAutoSwitchFrom; //0x0179 131 | char pad_017A[2]; //0x017A 132 | int32_t iFlags; //0x017C 133 | char szAmmo1[MAX_WEAPON_AMMO_NAME]; //0x0180 134 | char szAmmo2[MAX_WEAPON_AMMO_NAME]; //0x01A0 135 | char aShootSounds[NUM_SHOOT_SOUND_TYPES][MAX_WEAPON_STRING]; //0x01C0 136 | int32_t iAmmoType; //0x06C0 137 | int32_t iAmmo2Type; //0x06C4 138 | bool m_bMeleeWeapon; //0x06C8 139 | bool m_bBuiltRightHanded; //0x06C9 140 | bool m_bAllowFlipping; //0x06CA 141 | char pad_06CB[1]; //0x06CB 142 | int32_t iSpriteCount; //0x06CC 143 | class CHudTexture* iconActive; //0x06D0 144 | class CHudTexture* iconInactive; //0x06D4 145 | class CHudTexture* iconAmmo; //0x06D8 146 | class CHudTexture* iconAmmo2; //0x06DC 147 | class CHudTexture* iconCrosshair; //0x06E0 148 | class CHudTexture* iconAutoaim; //0x06E4 149 | class CHudTexture* iconZoomedCrosshair; //0x06E8 150 | class CHudTexture* iconZoomedAutoaim; //0x06EC 151 | class CHudTexture* iconSmall; //0x06F0 152 | bool bShowUsageHint; //0x06F4 153 | char pad_06F5[3]; //0x06F5 154 | float m_flMaxSpeed; //0x06F8 155 | int32_t m_WeaponType; //0x06FC 156 | bool bFullAuto; //0x0700 157 | char pad_0701[3]; //0x0701 158 | int32_t m_iTeam; //0x0704 159 | float m_flBotAudibleRange; //0x0708 160 | float m_flArmorRatio; //0x070C 161 | int32_t m_iCrosshairMinDistance; //0x0710 162 | int32_t m_iCrosshairDeltaDistance; //0x0714 163 | bool m_bCanUseWithShield; //0x0718 164 | char m_WrongTeamMsg[32]; //0x0719 165 | char m_szAnimExtension[16]; //0x0739 166 | char m_szShieldViewModel[64]; //0x0749 167 | char m_szAddonModel[MAX_WEAPON_STRING]; //0x0789 168 | char m_szDroppedModel[MAX_WEAPON_STRING]; //0x07D9 169 | char m_szSilencerModel[MAX_WEAPON_STRING]; //0x0829 170 | char pad_0879[3]; //0x0879 171 | int32_t m_iMuzzleFlashStyle; //0x087C 172 | float m_flMuzzleScale; //0x0880 173 | int32_t m_iPenetration; //0x0884 174 | int32_t m_iDamage; //0x0888 175 | float m_flRange; //0x088C 176 | float m_flRangeModifier; //0x0890 177 | int32_t m_iBullets; //0x0894 178 | float m_flCycleTime; //0x0898 179 | bool m_bAccuracyQuadratic; //0x089C 180 | char pad_089D[3]; //0x089D 181 | float m_flAccuracyDivisor; //0x08A0 182 | float m_flAccuracyOffset; //0x08A4 183 | float m_flMaxInaccuracy; //0x08A8 184 | float m_flSpread; //0x08AC 185 | float m_flSpreadAlt; //0x08B0 186 | float m_flInaccuracyCrouch; //0x08B4 187 | float m_flInaccuracyCrouchAlt; //0x08B8 188 | float m_flInaccuracyStand; //0x08BC 189 | float m_flInaccuracyStandAlt; //0x08C0 190 | float m_flInaccuracyJump; //0x08C4 191 | float m_flInaccuracyJumpAlt; //0x08C8 192 | float m_flInaccuracyLand; //0x08CC 193 | float m_flInaccuracyLandAlt; //0x08D0 194 | float m_flInaccuracyLadder; //0x08D4 195 | float m_flInaccuracyLadderAlt; //0x08D8 196 | float m_flInaccuracyFire; //0x08DC 197 | float m_flInaccuracyFireAlt; //0x08E0 198 | float m_flInaccuracyMove; //0x08E4 199 | float m_flInaccuracyMoveAlt; //0x08E8 200 | float m_flRecoveryTimeStand; //0x08EC 201 | float m_flRecoveryTimeCrouch; //0x08F0 202 | float m_flInaccuracyReload; //0x08F4 203 | float m_flInaccuracyAltSwitch; //0x08F8 204 | float m_flTimeToIdleAfterFire; //0x08FC 205 | float m_flIdleInterval; //0x0900 206 | int32_t m_iWeaponPrice; //0x0904 207 | int32_t m_iDefaultPrice; //0x0908 208 | int32_t m_iPreviousPrice; //0x090C 209 | }; //Size: 0x0910 210 | 211 | #pragma pack(pop) 212 | 213 | class C_BaseCombatWeapon : public C_BaseEntity 214 | { 215 | public: 216 | NETVAR(get_clip, "CBaseCombatWeapon", "m_iClip1", int); 217 | NETVAR(get_next_primary_attack, "CBaseCombatWeapon", "m_flNextPrimaryAttack", float); 218 | NETVAR(get_weapon_mode, "CWeaponCSBase", "m_weaponMode", int); 219 | NETVAR(get_accuracy_penalty, "CWeaponCSBase", "m_fAccuracyPenalty", float); 220 | 221 | bool IsFullAuto() 222 | { 223 | return get_vfunc(this, 363)(this); 224 | } 225 | 226 | int GetWeaponID() 227 | { 228 | return get_vfunc(this, 365)(this); 229 | } 230 | 231 | float GetInaccuracy() 232 | { 233 | return get_vfunc(this, 376)(this); 234 | } 235 | 236 | float GetSpread() 237 | { 238 | return get_vfunc(this, 377)(this); 239 | } 240 | 241 | void UpdateAccuracyPenalty() 242 | { 243 | return get_vfunc(this, 378)(this); 244 | } 245 | 246 | CCSWeaponInfo* GetWpnData() 247 | { 248 | static uint64_t oGetWpnData = tools::find_pattern("client.dll", "0F B7 81 ? ? ? ? 50 E8 ? ? ? ? 83 C4 04 C3"); 249 | return reinterpret_cast(oGetWpnData)(this); 250 | } 251 | }; -------------------------------------------------------------------------------- /src/SDK/CInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MULTIPLAYER_BACKUP 90 4 | 5 | class CUserCmd 6 | { 7 | public: 8 | CUserCmd() 9 | { 10 | Reset(); 11 | } 12 | 13 | virtual ~CUserCmd() { }; 14 | 15 | void Reset() 16 | { 17 | command_number = 0; 18 | tick_count = 0; 19 | viewangles.Init(); 20 | forwardmove = 0.0f; 21 | sidemove = 0.0f; 22 | upmove = 0.0f; 23 | buttons = 0; 24 | impulse = 0; 25 | weaponselect = 0; 26 | weaponsubtype = 0; 27 | random_seed = 0; 28 | mousedx = 0; 29 | mousedy = 0; 30 | 31 | hasbeenpredicted = false; 32 | } 33 | 34 | CUserCmd& operator =(const CUserCmd& src) 35 | { 36 | if (this == &src) 37 | return *this; 38 | 39 | command_number = src.command_number; 40 | tick_count = src.tick_count; 41 | viewangles = src.viewangles; 42 | forwardmove = src.forwardmove; 43 | sidemove = src.sidemove; 44 | upmove = src.upmove; 45 | buttons = src.buttons; 46 | impulse = src.impulse; 47 | weaponselect = src.weaponselect; 48 | weaponsubtype = src.weaponsubtype; 49 | random_seed = src.random_seed; 50 | mousedx = src.mousedx; 51 | mousedy = src.mousedy; 52 | 53 | hasbeenpredicted = src.hasbeenpredicted; 54 | 55 | return *this; 56 | } 57 | 58 | CUserCmd(const CUserCmd& src) 59 | { 60 | *this = src; 61 | } 62 | 63 | CRC32_t GetChecksum(void) const 64 | { 65 | CRC32_t crc; 66 | 67 | CRC32_Init(&crc); 68 | CRC32_ProcessBuffer(&crc, &command_number, sizeof(command_number)); 69 | CRC32_ProcessBuffer(&crc, &tick_count, sizeof(tick_count)); 70 | CRC32_ProcessBuffer(&crc, &viewangles, sizeof(viewangles)); 71 | CRC32_ProcessBuffer(&crc, &forwardmove, sizeof(forwardmove)); 72 | CRC32_ProcessBuffer(&crc, &sidemove, sizeof(sidemove)); 73 | CRC32_ProcessBuffer(&crc, &upmove, sizeof(upmove)); 74 | CRC32_ProcessBuffer(&crc, &buttons, sizeof(buttons)); 75 | CRC32_ProcessBuffer(&crc, &impulse, sizeof(impulse)); 76 | CRC32_ProcessBuffer(&crc, &weaponselect, sizeof(weaponselect)); 77 | CRC32_ProcessBuffer(&crc, &weaponsubtype, sizeof(weaponsubtype)); 78 | CRC32_ProcessBuffer(&crc, &random_seed, sizeof(random_seed)); 79 | CRC32_ProcessBuffer(&crc, &mousedx, sizeof(mousedx)); 80 | CRC32_ProcessBuffer(&crc, &mousedy, sizeof(mousedy)); 81 | CRC32_Final(&crc); 82 | 83 | return crc; 84 | } 85 | 86 | // Allow command, but negate gameplay-affecting values 87 | void MakeInert(void) 88 | { 89 | viewangles = { 0.f, 0.f, 0.f}; 90 | forwardmove = 0.f; 91 | sidemove = 0.f; 92 | upmove = 0.f; 93 | buttons = 0; 94 | impulse = 0; 95 | } 96 | 97 | // For matching server and client commands for debugging 98 | int command_number; 99 | 100 | // the tick the client created this command 101 | int tick_count; 102 | 103 | // Player instantaneous view angles. 104 | QAngle viewangles; 105 | // Intended velocities 106 | // forward velocity. 107 | float forwardmove; 108 | // sideways velocity. 109 | float sidemove; 110 | // upward velocity. 111 | float upmove; 112 | // Attack button states 113 | int buttons; 114 | // Impulse command issued. 115 | byte impulse; 116 | // Current weapon id 117 | int weaponselect; 118 | int weaponsubtype; 119 | 120 | int random_seed; // For shared random functions 121 | 122 | short mousedx; // mouse accum in x from create move 123 | short mousedy; // mouse accum in y from create move 124 | 125 | // Client only, tracks whether we've predicted this command at least once 126 | bool hasbeenpredicted; 127 | }; 128 | 129 | class CVerifiedUserCmd 130 | { 131 | public: 132 | CUserCmd m_cmd; 133 | CRC32_t m_crc; 134 | }; 135 | 136 | class CInput 137 | { 138 | public: 139 | char pad_0x0000[0x8C]; //0x0000 140 | unsigned char N00000024; //0x008C 141 | unsigned char m_fCameraInThirdPerson; //0x008D 142 | char pad_0x008E[0x16]; //0x008E 143 | Vector m_angPreviousViewAngles; //0x00A4 144 | float m_flLastForwardMove; //0x00B0 145 | char pad_0x00B4[0x10]; //0x00B4 146 | CUserCmd* m_pCommands; //0x00C4 147 | CVerifiedUserCmd * m_pVerifiedCommands; //0x00C8 148 | 149 | }; //Size=0x00CC -------------------------------------------------------------------------------- /src/SDK/CRC.cpp: -------------------------------------------------------------------------------- 1 | #include "CRC.h" 2 | 3 | #define BigShort( val ) WordSwap( val ) 4 | #define BigWord( val ) WordSwap( val ) 5 | #define BigLong( val ) DWordSwap( val ) 6 | #define BigDWord( val ) DWordSwap( val ) 7 | #define LittleShort( val ) ( val ) 8 | #define LittleWord( val ) ( val ) 9 | #define LittleLong( val ) ( val ) 10 | #define LittleDWord( val ) ( val ) 11 | #define SwapShort( val ) BigShort( val ) 12 | #define SwapWord( val ) BigWord( val ) 13 | #define SwapLong( val ) BigLong( val ) 14 | #define SwapDWord( val ) BigDWord( val ) 15 | 16 | #define CRC32_INIT_VALUE 0xFFFFFFFFUL 17 | #define CRC32_XOR_VALUE 0xFFFFFFFFUL 18 | 19 | #define NUM_BYTES 256 20 | static const CRC32_t pulCRCTable[NUM_BYTES] = 21 | { 22 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 23 | 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 24 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 25 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 26 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 27 | 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 28 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 29 | 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 30 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 31 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 32 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 33 | 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 34 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 35 | 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 36 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 37 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 38 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 39 | 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 40 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 41 | 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 42 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 43 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 44 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 45 | 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 46 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 47 | 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 48 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 49 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 50 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 51 | 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 52 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 53 | 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 54 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 55 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 56 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 57 | 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 58 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 59 | 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 60 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 61 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 62 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 63 | 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 64 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 65 | 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 66 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 67 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 68 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 69 | 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 70 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 71 | 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 72 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 73 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 74 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 75 | 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 76 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 77 | 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 78 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 79 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 80 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 81 | 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 82 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 83 | 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 84 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 85 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 86 | }; 87 | 88 | void CRC32_Init(CRC32_t *pulCRC) 89 | { 90 | *pulCRC = CRC32_INIT_VALUE; 91 | } 92 | 93 | void CRC32_Final(CRC32_t *pulCRC) 94 | { 95 | *pulCRC ^= CRC32_XOR_VALUE; 96 | } 97 | 98 | CRC32_t CRC32_GetTableEntry(unsigned int slot) 99 | { 100 | return pulCRCTable[(unsigned char)slot]; 101 | } 102 | 103 | void CRC32_ProcessBuffer(CRC32_t *pulCRC, const void *pBuffer, int nBuffer) 104 | { 105 | CRC32_t ulCrc = *pulCRC; 106 | unsigned char *pb = (unsigned char *)pBuffer; 107 | unsigned int nFront; 108 | int nMain; 109 | 110 | JustAfew: 111 | 112 | switch (nBuffer) { 113 | case 7: 114 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 115 | 116 | case 6: 117 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 118 | 119 | case 5: 120 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 121 | 122 | case 4: 123 | ulCrc ^= LittleLong(*(CRC32_t *)pb); 124 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 125 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 126 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 127 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 128 | *pulCRC = ulCrc; 129 | return; 130 | 131 | case 3: 132 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 133 | 134 | case 2: 135 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 136 | 137 | case 1: 138 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 139 | 140 | case 0: 141 | *pulCRC = ulCrc; 142 | return; 143 | } 144 | 145 | // We may need to do some alignment work up front, and at the end, so that 146 | // the main loop is aligned and only has to worry about 8 byte at a time. 147 | // 148 | // The low-order two bits of pb and nBuffer in total control the 149 | // upfront work. 150 | // 151 | nFront = ((unsigned int)pb) & 3; 152 | nBuffer -= nFront; 153 | switch (nFront) { 154 | case 3: 155 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 156 | case 2: 157 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 158 | case 1: 159 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 160 | } 161 | 162 | nMain = nBuffer >> 3; 163 | while (nMain--) { 164 | ulCrc ^= LittleLong(*(CRC32_t *)pb); 165 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 166 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 167 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 168 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 169 | ulCrc ^= LittleLong(*(CRC32_t *)(pb + 4)); 170 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 171 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 172 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 173 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 174 | pb += 8; 175 | } 176 | 177 | nBuffer &= 7; 178 | goto JustAfew; 179 | } -------------------------------------------------------------------------------- /src/SDK/CRC.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned long CRC32_t; 4 | 5 | void CRC32_Init(CRC32_t *pulCRC); 6 | void CRC32_ProcessBuffer(CRC32_t *pulCRC, const void *p, int len); 7 | void CRC32_Final(CRC32_t *pulCRC); 8 | CRC32_t CRC32_GetTableEntry(unsigned int slot); 9 | 10 | inline CRC32_t CRC32_ProcessSingleBuffer(const void *p, int len) 11 | { 12 | CRC32_t crc; 13 | 14 | CRC32_Init(&crc); 15 | CRC32_ProcessBuffer(&crc, p, len); 16 | CRC32_Final(&crc); 17 | 18 | return crc; 19 | } -------------------------------------------------------------------------------- /src/SDK/Color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #pragma warning(push) 7 | #pragma warning(disable:4333 4244) 8 | 9 | #define DEFCOLOR_SRC(name, r, g, b) static Color name##(uint8_t a = 255){ \ 10 | return Color(r, g, b, a); \ 11 | } 12 | class Color 13 | { 14 | public: 15 | // constructors 16 | Color() 17 | { 18 | *((int *)this) = 0; 19 | } 20 | Color(uint8_t r, uint8_t g, uint8_t b) 21 | { 22 | SetColor(r, g, b, 255); 23 | } 24 | Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) 25 | { 26 | SetColor(r, g, b, a); 27 | } 28 | void SetColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0) 29 | { 30 | _color[0] = (uint8_t)r; 31 | _color[1] = (uint8_t)g; 32 | _color[2] = (uint8_t)b; 33 | _color[3] = (uint8_t)a; 34 | } 35 | 36 | void GetColor(uint8_t &r, uint8_t &g, uint8_t &b, uint8_t &a) const 37 | { 38 | r = _color[0]; 39 | g = _color[1]; 40 | b = _color[2]; 41 | a = _color[3]; 42 | } 43 | 44 | void GetColor(int &_r, int &_g, int &_b, int &_a) const 45 | { 46 | _r = _color[0]; 47 | _g = _color[1]; 48 | _b = _color[2]; 49 | _a = _color[3]; 50 | } 51 | 52 | static Color FromARGB(unsigned long color) 53 | { 54 | int a = (color & 0xFF000000) >> 24; 55 | int r = (color & 0x00FF0000) >> 16; 56 | int g = (color & 0x0000FF00) >> 8; 57 | int b = (color & 0x000000FF); 58 | 59 | return Color(r, g, b, a); 60 | } 61 | 62 | void SetARGB(unsigned long color) 63 | { 64 | int a = (color & 0xFF000000) >> 24; 65 | int r = (color & 0x00FF0000) >> 16; 66 | int g = (color & 0x0000FF00) >> 8; 67 | int b = (color & 0x000000FF); 68 | 69 | SetColor(r, g, b, a); 70 | } 71 | 72 | DWORD GetARGB() const 73 | { 74 | int a = (_color[3]) >> 24; 75 | int r = (_color[0]) >> 16; 76 | int g = (_color[1]) >> 8; 77 | int b = (_color[2]); 78 | 79 | return a | r | g | b; 80 | } 81 | 82 | static Color FromHSB(float hue, float saturation, float brightness) 83 | { 84 | float h = hue == 1.0f ? 0 : hue * 6.0f; 85 | float f = h - (int)h; 86 | float p = brightness * (1.0f - saturation); 87 | float q = brightness * (1.0f - saturation * f); 88 | float t = brightness * (1.0f - (saturation * (1.0f - f))); 89 | 90 | if (h < 1) 91 | { 92 | return Color( 93 | (unsigned char)(brightness * 255), 94 | (unsigned char)(t * 255), 95 | (unsigned char)(p * 255) 96 | ); 97 | } 98 | else if (h < 2) 99 | { 100 | return Color( 101 | (unsigned char)(q * 255), 102 | (unsigned char)(brightness * 255), 103 | (unsigned char)(p * 255) 104 | ); 105 | } 106 | else if (h < 3) 107 | { 108 | return Color( 109 | (unsigned char)(p * 255), 110 | (unsigned char)(brightness * 255), 111 | (unsigned char)(t * 255) 112 | ); 113 | } 114 | else if (h < 4) 115 | { 116 | return Color( 117 | (unsigned char)(p * 255), 118 | (unsigned char)(q * 255), 119 | (unsigned char)(brightness * 255) 120 | ); 121 | } 122 | else if (h < 5) 123 | { 124 | return Color( 125 | (unsigned char)(t * 255), 126 | (unsigned char)(p * 255), 127 | (unsigned char)(brightness * 255) 128 | ); 129 | } 130 | else 131 | { 132 | return Color( 133 | (unsigned char)(brightness * 255), 134 | (unsigned char)(p * 255), 135 | (unsigned char)(q * 255) 136 | ); 137 | } 138 | } 139 | 140 | uint8_t &operator[](int index) 141 | { 142 | return _color[index]; 143 | } 144 | 145 | const uint8_t &operator[](int index) const 146 | { 147 | return _color[index]; 148 | } 149 | 150 | bool operator == (const Color &rhs) const 151 | { 152 | return (*((int *)this) == *((int *)&rhs)); 153 | } 154 | 155 | bool operator != (const Color &rhs) const 156 | { 157 | return !(operator==(rhs)); 158 | } 159 | 160 | int r() { return _color[0]; } 161 | int g() { return _color[1]; } 162 | int b() { return _color[2]; } 163 | int a() { return _color[3]; } 164 | 165 | int GetR() { return _color[0]; } 166 | int GetG() { return _color[1]; } 167 | int GetB() { return _color[2]; } 168 | int GetA() { return _color[3]; } 169 | 170 | void SetR(uint8_t _i) { _color[0] = _i; } 171 | void SetG(uint8_t _i) { _color[1] = _i; } 172 | void SetB(uint8_t _i) { _color[2] = _i; } 173 | void SetA(uint8_t _i) { _color[3] = _i; } 174 | 175 | Color &operator=(const Color &rhs) 176 | { 177 | *(int*)(&_color[0]) = *(int*)&rhs._color[0]; 178 | return *this; 179 | } 180 | 181 | Color operator+(const Color &rhs) const 182 | { 183 | int red = _color[0] + rhs._color[0]; 184 | int green = _color[1] + rhs._color[1]; 185 | int blue = _color[2] + rhs._color[2]; 186 | int alpha = _color[3] + rhs._color[3]; 187 | 188 | red = red > 255 ? 255 : red; 189 | green = green > 255 ? 255 : green; 190 | blue = blue > 255 ? 255 : blue; 191 | alpha = alpha > 255 ? 255 : alpha; 192 | 193 | return Color(red, green, blue, alpha); 194 | } 195 | 196 | Color operator-(const Color &rhs) const 197 | { 198 | int red = _color[0] - rhs._color[0]; 199 | int green = _color[1] - rhs._color[1]; 200 | int blue = _color[2] - rhs._color[2]; 201 | int alpha = _color[3] - rhs._color[3]; 202 | 203 | red = red < 0 ? 0 : red; 204 | green = green < 0 ? 0 : green; 205 | blue = blue < 0 ? 0 : blue; 206 | alpha = alpha < 0 ? 0 : alpha; 207 | return Color(red, green, blue, alpha); 208 | } 209 | 210 | float* Base() 211 | { 212 | float clr[3]; 213 | 214 | clr[0] = _color[0] / 255.0f; 215 | clr[1] = _color[1] / 255.0f; 216 | clr[2] = _color[2] / 255.0f; 217 | 218 | return &clr[0]; 219 | } 220 | 221 | inline float rBase() const { return _color[0] / 255.0f; } 222 | inline float gBase() const { return _color[1] / 255.0f; } 223 | inline float bBase() const { return _color[2] / 255.0f; } 224 | inline float aBase() const { return _color[3] / 255.0f; } 225 | 226 | operator const uint8_t*() 227 | { 228 | return (uint8_t*)(&_color[0]); 229 | } 230 | 231 | DEFCOLOR_SRC(Black, 0, 0, 0); 232 | DEFCOLOR_SRC(White, 255, 255, 255); 233 | DEFCOLOR_SRC(Red, 255, 0, 0); 234 | DEFCOLOR_SRC(Green, 0, 128, 0); 235 | DEFCOLOR_SRC(Blue, 0, 0, 255); 236 | DEFCOLOR_SRC(Lime, 0, 255, 0); 237 | DEFCOLOR_SRC(Yellow, 255, 255, 0); 238 | DEFCOLOR_SRC(Cyan, 0, 255, 255); 239 | DEFCOLOR_SRC(Magenta, 255, 0, 255); 240 | DEFCOLOR_SRC(Silver, 192, 192, 192); 241 | DEFCOLOR_SRC(Gray, 128, 128, 128); 242 | DEFCOLOR_SRC(Maroon, 128, 0, 0); 243 | DEFCOLOR_SRC(Olive, 128, 128, 0); 244 | DEFCOLOR_SRC(Purple, 128, 0, 128); 245 | DEFCOLOR_SRC(Teal, 0, 128, 128); 246 | DEFCOLOR_SRC(Navy, 0, 0, 128); 247 | DEFCOLOR_SRC(DarkRed, 139, 0, 0); 248 | DEFCOLOR_SRC(Brown, 165, 42, 42); 249 | DEFCOLOR_SRC(Firebrick, 178, 34, 34); 250 | DEFCOLOR_SRC(Crimson, 220, 20, 60); 251 | DEFCOLOR_SRC(IndianRed, 205, 92, 92); 252 | DEFCOLOR_SRC(LightCoral, 240, 128, 128); 253 | DEFCOLOR_SRC(DarkSalmon, 233, 150, 122); 254 | DEFCOLOR_SRC(Salmon, 250, 128, 114); 255 | DEFCOLOR_SRC(LightSalmon, 255, 160, 122); 256 | DEFCOLOR_SRC(OrangeRed, 255, 69, 0); 257 | DEFCOLOR_SRC(DarkOrange, 255, 140, 0); 258 | DEFCOLOR_SRC(Orange, 255, 165, 0); 259 | DEFCOLOR_SRC(Gold, 255, 215, 0); 260 | DEFCOLOR_SRC(DarkGoldenRod, 184, 134, 11); 261 | DEFCOLOR_SRC(GoldenRod, 218, 165, 32); 262 | DEFCOLOR_SRC(YellowGreen, 154, 205, 50); 263 | DEFCOLOR_SRC(DarkOliveGreen, 85, 107, 47); 264 | DEFCOLOR_SRC(OliveDrab, 107, 142, 35); 265 | DEFCOLOR_SRC(LawnGreen, 124, 252, 0); 266 | DEFCOLOR_SRC(ChartReuse, 127, 255, 0); 267 | DEFCOLOR_SRC(GreenYellow, 173, 255, 47); 268 | DEFCOLOR_SRC(DarkGreen, 0, 100, 0); 269 | DEFCOLOR_SRC(ForestGreen, 34, 139, 34); 270 | DEFCOLOR_SRC(LimeGreen, 50, 205, 50); 271 | DEFCOLOR_SRC(DarkCyan, 0, 139, 139); 272 | DEFCOLOR_SRC(Aqua, 0, 255, 255); 273 | DEFCOLOR_SRC(LightCyan, 224, 255, 255); 274 | DEFCOLOR_SRC(DarkTurquoise, 0, 206, 209); 275 | DEFCOLOR_SRC(Turquoise, 64, 224, 208); 276 | DEFCOLOR_SRC(MediumTurquoise, 72, 209, 204); 277 | DEFCOLOR_SRC(PaleTurquoise, 175, 238, 238); 278 | DEFCOLOR_SRC(Aquamarine, 127, 255, 212); 279 | DEFCOLOR_SRC(PowderBlue, 176, 224, 230); 280 | DEFCOLOR_SRC(DodgerBlue, 30, 144, 255); 281 | DEFCOLOR_SRC(Lightblue, 173, 216, 230); 282 | DEFCOLOR_SRC(SkyBlue, 135, 206, 235); 283 | DEFCOLOR_SRC(LightSkyBlue, 135, 206, 250); 284 | DEFCOLOR_SRC(MidnightBlue, 25, 25, 112); 285 | DEFCOLOR_SRC(DarkBlue, 0, 0, 139); 286 | DEFCOLOR_SRC(MediumBlue, 0, 0, 205); 287 | DEFCOLOR_SRC(RoyalBlue, 65, 105, 225); 288 | DEFCOLOR_SRC(BlueViolet, 138, 43, 226); 289 | DEFCOLOR_SRC(Indigo, 75, 0, 130); 290 | DEFCOLOR_SRC(DarkSlateBlue, 72, 61, 139); 291 | DEFCOLOR_SRC(SlateBlue, 106, 90, 205); 292 | DEFCOLOR_SRC(MediumSlateBlue, 123, 104, 238); 293 | DEFCOLOR_SRC(MediumPurple, 147, 112, 219); 294 | DEFCOLOR_SRC(Darkmagenta, 139, 0, 139); 295 | DEFCOLOR_SRC(Darkviolet, 148, 0, 211); 296 | DEFCOLOR_SRC(DarkGray, 169, 169, 169); 297 | DEFCOLOR_SRC(LightGray, 211, 211, 211); 298 | DEFCOLOR_SRC(Gainsboro, 220, 220, 220); 299 | private: 300 | uint8_t _color[4]; 301 | }; 302 | 303 | #pragma warning(pop) -------------------------------------------------------------------------------- /src/SDK/IAppSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "definitions.h" 4 | 5 | enum InitReturnVal_t 6 | { 7 | INIT_FAILED = 0, 8 | INIT_OK, 9 | 10 | INIT_LAST_VAL, 11 | }; 12 | 13 | class IAppSystem 14 | { 15 | virtual bool Connect(CreateInterfaceFn factory) = 0; 16 | virtual void Disconnect() = 0; 17 | virtual void *QueryInterface(const char *pInterfaceName) = 0; 18 | virtual InitReturnVal_t Init() = 0; 19 | virtual void Shutdown() = 0; 20 | }; -------------------------------------------------------------------------------- /src/SDK/IBaseClientDll.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sdk.h" 4 | #include "../tools/virtuals.h" 5 | 6 | class DVariant; 7 | class CRecvProxyData; 8 | class RecvProp; 9 | class RecvTable; 10 | 11 | typedef void*(*CreateClientClassFn)(int entnum, int serialNum); 12 | typedef void*(*CreateEventFn)(); 13 | 14 | typedef void(*RecvVarProxyFn)(const CRecvProxyData *pData, void *pStruct, void *pOut); 15 | typedef void(*DataTableRecvVarProxyFn)(const RecvProp *pProp, void **pOut, void *pData, int objectID); 16 | typedef void(*ArrayLengthRecvProxyFn)(void *pStruct, int objectID, int currentArrayLength); 17 | 18 | typedef enum 19 | { 20 | DPT_Int = 0, 21 | DPT_Float, 22 | DPT_Vector, 23 | DPT_String, 24 | DPT_Array, // An array of the base types (can't be of datatables). 25 | DPT_DataTable 26 | } SendPropType; 27 | 28 | class DVariant 29 | { 30 | public: 31 | union 32 | { 33 | float m_Float; 34 | long m_Int; 35 | char *m_pString; 36 | void *m_pData; 37 | float m_Vector[3]; 38 | long long m_Int64; 39 | }; 40 | 41 | SendPropType m_Type; 42 | }; 43 | 44 | class CRecvProxyData 45 | { 46 | public: 47 | const RecvProp *m_pRecvProp; 48 | DVariant m_Value; 49 | int m_iElement; 50 | int m_ObjectID; 51 | }; 52 | 53 | class RecvProp 54 | { 55 | public: 56 | int GetFlags() const 57 | { 58 | return m_Flags; 59 | } 60 | 61 | const char* GetName() const 62 | { 63 | return m_pVarName; 64 | } 65 | 66 | int GetType() const 67 | { 68 | return m_RecvType; 69 | } 70 | 71 | RecvTable* GetDataTable() const 72 | { 73 | return m_pDataTable; 74 | } 75 | 76 | RecvVarProxyFn GetProxyFn() const 77 | { 78 | return m_ProxyFn; 79 | } 80 | 81 | void SetProxyFn(RecvVarProxyFn fn) 82 | { 83 | m_ProxyFn = fn; 84 | } 85 | 86 | int GetOffset() const 87 | { 88 | return m_Offset; 89 | } 90 | 91 | void SetOffset(int o) 92 | { 93 | m_Offset = o; 94 | } 95 | 96 | public: 97 | char *m_pVarName; 98 | int m_RecvType; 99 | int m_Flags; 100 | int m_StringBufferSize; 101 | 102 | bool m_bInsideArray; 103 | 104 | const void* m_pExtraData; 105 | 106 | RecvProp *m_pArrayProp; 107 | ArrayLengthRecvProxyFn m_ArrayLengthProxy; 108 | 109 | RecvVarProxyFn m_ProxyFn; 110 | DataTableRecvVarProxyFn m_DataTableProxyFn; 111 | 112 | RecvTable *m_pDataTable; 113 | int m_Offset; 114 | 115 | int m_ElementStride; 116 | int m_nElements; 117 | 118 | const char *m_pParentArrayPropName; 119 | }; 120 | 121 | class RecvTable 122 | { 123 | public: 124 | int GetNumProps() 125 | { 126 | return m_nProps; 127 | } 128 | 129 | RecvProp* GetRecvProp(int i) 130 | { 131 | return &m_pProps[i]; 132 | } 133 | 134 | const char* GetName() 135 | { 136 | return m_pNetTableName; 137 | } 138 | 139 | public: 140 | RecvProp *m_pProps; 141 | int m_nProps; 142 | 143 | void* m_pDecoder; 144 | 145 | char *m_pNetTableName; 146 | 147 | bool m_bInitialized; 148 | bool m_bInMainList; 149 | }; 150 | 151 | enum ClientFrameStage_t 152 | { 153 | FRAME_UNDEFINED = -1, // (haven't run any frames yet) 154 | FRAME_START, 155 | 156 | // A network packet is being recieved 157 | FRAME_NET_UPDATE_START, 158 | // Data has been received and we're going to start calling PostDataUpdate 159 | FRAME_NET_UPDATE_POSTDATAUPDATE_START, 160 | // Data has been received and we've called PostDataUpdate on all data recipients 161 | FRAME_NET_UPDATE_POSTDATAUPDATE_END, 162 | // We've received all packets, we can now do interpolation, prediction, etc.. 163 | FRAME_NET_UPDATE_END, 164 | 165 | // We're about to start rendering the scene 166 | FRAME_RENDER_START, 167 | // We've finished rendering the scene. 168 | FRAME_RENDER_END 169 | }; 170 | 171 | struct ClientClass 172 | { 173 | CreateClientClassFn m_pCreateFn; 174 | CreateEventFn m_pCreateEventFn; 175 | char *m_pNetworkName; 176 | RecvTable *m_pRecvTable; 177 | ClientClass *m_pNext; 178 | int m_ClassID; 179 | 180 | const char* GetName() 181 | { 182 | return m_pNetworkName; 183 | } 184 | }; 185 | 186 | class IBaseClientDll 187 | { 188 | public: 189 | ClientClass* GetAllClasses() 190 | { 191 | typedef ClientClass* (__thiscall* GetAllClassesFn)(void*); 192 | return get_vfunc(this, 8)(this); 193 | } 194 | }; -------------------------------------------------------------------------------- /src/SDK/ICVar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IAppSystem.h" 4 | #include "IConVar.h" 5 | 6 | class ConCommandBase; 7 | class ConCommand; 8 | class ConVar; 9 | 10 | typedef int CVarDLLIdentifier_t; 11 | 12 | class IConsoleDisplayFunc 13 | { 14 | public: 15 | virtual void ColorPrint(const uint8_t* clr, const char *pMessage) = 0; 16 | virtual void Print(const char *pMessage) = 0; 17 | virtual void DPrint(const char *pMessage) = 0; 18 | }; 19 | 20 | class ICvar : public IAppSystem 21 | { 22 | public: 23 | virtual CVarDLLIdentifier_t AllocateDLLIdentifier() = 0; 24 | virtual void RegisterConCommand(ConCommandBase *pCommandBase) = 0; 25 | virtual void UnregisterConCommand(ConCommandBase *pCommandBase) = 0; 26 | virtual void UnregisterConCommands(CVarDLLIdentifier_t id) = 0; 27 | virtual const char* GetCommandLineValue(const char *pVariableName) = 0; 28 | virtual ConCommandBase* FindCommandBase(const char *name) = 0; 29 | virtual const ConCommandBase* FindCommandBase(const char *name) const = 0; 30 | virtual ConVar* FindVar(const char *var_name) = 0; 31 | virtual const ConVar* FindVar(const char *var_name) const = 0; 32 | virtual ConCommand* FindCommand(const char *name) = 0; 33 | virtual const ConCommand* FindCommand(const char *name) const = 0; 34 | virtual ConCommandBase* GetCommands(void) = 0; 35 | virtual const ConCommandBase* GetCommands(void) const = 0; 36 | virtual void InstallGlobalChangeCallback(FnChangeCallback_t callback) = 0; 37 | virtual void RemoveGlobalChangeCallback(FnChangeCallback_t callback) = 0; 38 | virtual void CallGlobalChangeCallbacks(ConVar *var, const char *pOldString, float flOldValue) = 0; 39 | virtual void InstallConsoleDisplayFunc(IConsoleDisplayFunc* pDisplayFunc) = 0; 40 | virtual void RemoveConsoleDisplayFunc(IConsoleDisplayFunc* pDisplayFunc) = 0; 41 | virtual void ConsoleColorPrintf(const uint8_t* clr, const char *pFormat, ...) const = 0; 42 | virtual void ConsolePrintf(const char *pFormat, ...) const = 0; 43 | virtual void ConsoleDPrintf(const char *pFormat, ...) const = 0; 44 | virtual void RevertFlaggedConVars(int nFlag) = 0; 45 | }; -------------------------------------------------------------------------------- /src/SDK/IClientEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SDK.h" 4 | #include "../tools/virtuals.h" 5 | #include "VMatrix.h" 6 | 7 | struct bf_read; 8 | using CBaseHandle = unsigned long; 9 | 10 | class IHandleEntity 11 | { 12 | public: 13 | virtual ~IHandleEntity() {}; 14 | }; 15 | 16 | class ICollideable; 17 | class IClientNetworkable; 18 | class IClientRenderable; 19 | class IClientEntity; 20 | class C_BaseEntity; 21 | class IClientThinkable; 22 | 23 | class IClientUnknown : public IHandleEntity 24 | { 25 | public: 26 | virtual ICollideable* GetCollideable() = 0; 27 | virtual IClientNetworkable* GetClientNetworkable() = 0; 28 | virtual IClientRenderable* GetClientRenderable() = 0; 29 | virtual IClientEntity* GetIClientEntity() = 0; 30 | virtual C_BaseEntity* GetBaseEntity() = 0; 31 | virtual IClientThinkable* GetClientThinkable() = 0; 32 | }; 33 | 34 | class CClientThinkHandlePtr; 35 | typedef CClientThinkHandlePtr* ClientThinkHandle_t; 36 | 37 | class IClientThinkable 38 | { 39 | public: 40 | // Gets at the containing class... 41 | virtual IClientUnknown* GetIClientUnknown() = 0; 42 | 43 | virtual void ClientThink() = 0; 44 | 45 | // Called when you're added to the think list. 46 | // GetThinkHandle's return value must be initialized to INVALID_THINK_HANDLE. 47 | virtual ClientThinkHandle_t GetThinkHandle() = 0; 48 | virtual void SetThinkHandle(ClientThinkHandle_t hThink) = 0; 49 | 50 | // Called by the client when it deletes the entity. 51 | virtual void Release() = 0; 52 | }; 53 | 54 | struct ClientShadowHandle_t; 55 | struct ClientRenderHandle_t; 56 | struct model_t; 57 | struct ShadowType_t; 58 | struct ModelInstanceHandle_t; 59 | 60 | class IPVSNotify; 61 | 62 | class IClientRenderable 63 | { 64 | public: 65 | // Gets at the containing class... 66 | virtual IClientUnknown* GetIClientUnknown() = 0; 67 | 68 | // Data accessors 69 | virtual Vector const& GetRenderOrigin(void) = 0; 70 | virtual QAngle const& GetRenderAngles(void) = 0; 71 | virtual bool ShouldDraw(void) = 0; 72 | virtual bool IsTransparent(void) = 0; 73 | virtual bool UsesPowerOfTwoFrameBufferTexture() = 0; 74 | virtual bool UsesFullFrameBufferTexture() = 0; 75 | 76 | virtual ClientShadowHandle_t GetShadowHandle() const = 0; 77 | 78 | // Used by the leaf system to store its render handle. 79 | virtual ClientRenderHandle_t& RenderHandle() = 0; 80 | 81 | // Render baby! 82 | virtual const model_t* GetModel() const = 0; 83 | virtual int DrawModel(int flags) = 0; 84 | 85 | // Get the body parameter 86 | virtual int GetBody() = 0; 87 | 88 | // Determine alpha and blend amount for transparent objects based on render state info 89 | virtual void ComputeFxBlend() = 0; 90 | virtual int GetFxBlend(void) = 0; 91 | 92 | // Determine the color modulation amount 93 | virtual void GetColorModulation(float* color) = 0; 94 | 95 | // Returns false if the entity shouldn't be drawn due to LOD. 96 | // (NOTE: This is no longer used/supported, but kept in the vtable for backwards compat) 97 | virtual bool LODTest() = 0; 98 | 99 | // Call this to get the current bone transforms for the model. 100 | // currentTime parameter will affect interpolation 101 | // nMaxBones specifies how many matrices pBoneToWorldOut can hold. (Should be greater than or 102 | // equal to studiohdr_t::numbones. Use MAXSTUDIOBONES to be safe.) 103 | virtual bool SetupBones(matrix3x4_t *pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime) = 0; 104 | 105 | virtual void SetupWeights(const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights) = 0; 106 | virtual void DoAnimationEvents(void) = 0; 107 | 108 | // Return this if you want PVS notifications. See IPVSNotify for more info. 109 | // Note: you must always return the same value from this function. If you don't, 110 | // undefined things will occur, and they won't be good. 111 | virtual IPVSNotify* GetPVSNotifyInterface() = 0; 112 | 113 | // Returns the bounds relative to the origin (render bounds) 114 | virtual void GetRenderBounds(Vector& mins, Vector& maxs) = 0; 115 | 116 | // returns the bounds as an AABB in worldspace 117 | virtual void GetRenderBoundsWorldspace(Vector& mins, Vector& maxs) = 0; 118 | 119 | // These normally call through to GetRenderAngles/GetRenderBounds, but some entities custom implement them. 120 | virtual void GetShadowRenderBounds(Vector &mins, Vector &maxs, ShadowType_t shadowType) = 0; 121 | 122 | // Should this object be able to have shadows cast onto it? 123 | virtual bool ShouldReceiveProjectedTextures(int flags) = 0; 124 | 125 | // These methods return true if we want a per-renderable shadow cast direction + distance 126 | virtual bool GetShadowCastDistance(float *pDist, ShadowType_t shadowType) const = 0; 127 | virtual bool GetShadowCastDirection(Vector *pDirection, ShadowType_t shadowType) const = 0; 128 | 129 | // Other methods related to shadow rendering 130 | virtual bool IsShadowDirty() = 0; 131 | virtual void MarkShadowDirty(bool bDirty) = 0; 132 | 133 | // Iteration over shadow hierarchy 134 | virtual IClientRenderable *GetShadowParent() = 0; 135 | virtual IClientRenderable *FirstShadowChild() = 0; 136 | virtual IClientRenderable *NextShadowPeer() = 0; 137 | 138 | // Returns the shadow cast type 139 | virtual ShadowType_t ShadowCastType() = 0; 140 | 141 | // Create/get/destroy model instance 142 | virtual void CreateModelInstance() = 0; 143 | virtual ModelInstanceHandle_t GetModelInstance() = 0; 144 | 145 | // Returns the transform from RenderOrigin/RenderAngles to world 146 | virtual const matrix3x4_t &RenderableToWorldTransform() = 0; 147 | 148 | // Attachments 149 | virtual int LookupAttachment(const char *pAttachmentName) = 0; 150 | virtual bool GetAttachment(int number, Vector &origin, QAngle &angles) = 0; 151 | virtual bool GetAttachment(int number, matrix3x4_t &matrix) = 0; 152 | 153 | // Rendering clip plane, should be 4 floats, return value of NULL indicates a disabled render clip plane 154 | virtual float *GetRenderClipPlane(void) = 0; 155 | 156 | // Get the skin parameter 157 | virtual int GetSkin() = 0; 158 | 159 | // Is this a two-pass renderable? 160 | virtual bool IsTwoPass(void) = 0; 161 | 162 | virtual void OnThreadedDrawSetup() = 0; 163 | 164 | virtual bool UsesFlexDelayedWeights() = 0; 165 | 166 | virtual void RecordToolMessage() = 0; 167 | 168 | virtual bool IgnoresZBuffer(void) const = 0; 169 | }; 170 | 171 | struct ClientClass; 172 | class IClientNetworkable 173 | { 174 | public: 175 | virtual IClientUnknown* GetIClientUnknown() = 0; 176 | virtual void Release() = 0; 177 | virtual ClientClass* GetClientClass() = 0; 178 | virtual void NotifyShouldTransmit(int state) = 0; 179 | virtual void OnPreDataChanged(int updateType) = 0; 180 | virtual void OnDataChanged(int updateType) = 0; 181 | virtual void PreDataUpdate(int updateType) = 0; 182 | virtual void PostDataUpdate(int updateType) = 0; 183 | virtual bool IsDormant() = 0; 184 | virtual int GetIndex() const = 0; 185 | virtual void ReceiveMessage(int classID, bf_read& msg) = 0; 186 | virtual void* GetDataTableBasePtr() = 0; 187 | virtual void SetDestroyedOnRecreateEntities() = 0; 188 | }; 189 | 190 | struct SpatializationInfo_t; 191 | 192 | class CMouthInfo; 193 | 194 | class IClientEntity : public IClientUnknown, public IClientRenderable, public IClientNetworkable, public IClientThinkable 195 | { 196 | public: 197 | // Delete yourself. 198 | virtual void Release(void) = 0; 199 | 200 | // Network origin + angles 201 | virtual const Vector& GetAbsOrigin(void) const = 0; 202 | virtual const QAngle& GetAbsAngles(void) const = 0; 203 | 204 | virtual CMouthInfo *GetMouth(void) = 0; 205 | 206 | // Retrieve sound spatialization info for the specified sound on this entity 207 | // Return false to indicate sound is not audible 208 | virtual bool GetSoundSpatialization(SpatializationInfo_t& info) = 0; 209 | }; -------------------------------------------------------------------------------- /src/SDK/IClientEntityList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class IClientEntity; 4 | class IClientUnknown; 5 | class IClientNetworkable; 6 | 7 | class IClientEntityList 8 | { 9 | public: 10 | virtual IClientNetworkable* GetClientNetworkable(int iEnt) = 0; 11 | virtual IClientNetworkable* GetClientNetworkableFromHandle(CBaseHandle hEnt) = 0; 12 | virtual IClientUnknown* GetClientUnknownFromHandle(CBaseHandle hEnt) = 0; 13 | virtual IClientEntity* GetClientEntity(int iEnt) = 0; 14 | virtual IClientEntity* GetClientEntityFromHandle(CBaseHandle hEnt) = 0; 15 | virtual int NumberOfEntities(bool bIncludeNonNetworkable) = 0; 16 | virtual int GetHighestEntityIndex() = 0; 17 | virtual void SetMaxEntities(int iMax) = 0; 18 | virtual int GetMaxEntities() = 0; 19 | }; -------------------------------------------------------------------------------- /src/SDK/IConVar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Color.h" 4 | 5 | //----------------------------------------------------------------------------- 6 | // Forward declarations 7 | //----------------------------------------------------------------------------- 8 | class IConVar; 9 | class CCommand; 10 | 11 | 12 | //----------------------------------------------------------------------------- 13 | // ConVar flags 14 | //----------------------------------------------------------------------------- 15 | // The default, no flags at all 16 | #define FCVAR_NONE 0 17 | 18 | // Command to ConVars and ConCommands 19 | // ConVar Systems 20 | #define FCVAR_UNREGISTERED (1<<0) // If this is set, don't add to linked list, etc. 21 | #define FCVAR_DEVELOPMENTONLY (1<<1) // Hidden in released products. Flag is removed automatically if ALLOW_DEVELOPMENT_CVARS is defined. 22 | #define FCVAR_GAMEDLL (1<<2) // defined by the game DLL 23 | #define FCVAR_CLIENTDLL (1<<3) // defined by the client DLL 24 | #define FCVAR_HIDDEN (1<<4) // Hidden. Doesn't appear in find or auto complete. Like DEVELOPMENTONLY, but can't be compiled out. 25 | 26 | // ConVar only 27 | #define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value 28 | #define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. 29 | #define FCVAR_ARCHIVE (1<<7) // set to cause it to be saved to vars.rc 30 | #define FCVAR_NOTIFY (1<<8) // notifies players when changed 31 | #define FCVAR_USERINFO (1<<9) // changes the client's info string 32 | 33 | #define FCVAR_PRINTABLEONLY (1<<10) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). 34 | #define FCVAR_UNLOGGED (1<<11) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log 35 | #define FCVAR_NEVER_AS_STRING (1<<12) // never try to print that cvar 36 | #define FCVAR_REPLICATED (1<<13) // server setting enforced on clients, TODO rename to FCAR_SERVER at some time 37 | #define FCVAR_CHEAT (1<<14) // Only useable in singleplayer / debug / multiplayer & sv_cheats 38 | #define FCVAR_SS (1<<15) // causes varnameN where N == 2 through max splitscreen slots for mod to be autogenerated 39 | #define FCVAR_DEMO (1<<16) // record this cvar when starting a demo file 40 | #define FCVAR_DONTRECORD (1<<17) // don't record these command in demofiles 41 | #define FCVAR_SS_ADDED (1<<18) // This is one of the "added" FCVAR_SS variables for the splitscreen players 42 | #define FCVAR_RELEASE (1<<19) // Cvars tagged with this are the only cvars avaliable to customers 43 | #define FCVAR_RELOAD_MATERIALS (1<<20) // If this cvar changes, it forces a material reload 44 | #define FCVAR_RELOAD_TEXTURES (1<<21) // If this cvar changes, if forces a texture reload 45 | #define FCVAR_NOT_CONNECTED (1<<22) // cvar cannot be changed by a client that is connected to a server 46 | #define FCVAR_MATERIAL_SYSTEM_THREAD (1<<23) // Indicates this cvar is read from the material system thread 47 | #define FCVAR_ARCHIVE_XBOX (1<<24) // cvar written to config.cfg on the Xbox 48 | #define FCVAR_ACCESSIBLE_FROM_THREADS (1<<25) // used as a debugging tool necessary to check material system thread convars 49 | //#define FCVAR_AVAILABLE (1<<26) 50 | //#define FCVAR_AVAILABLE (1<<27) 51 | #define FCVAR_SERVER_CAN_EXECUTE (1<<28) // the server is allowed to execute this command on clients via ClientCommand/NET_StringCmd/CBaseClientState::ProcessStringCmd. 52 | #define FCVAR_SERVER_CANNOT_QUERY (1<<29) // If this is set, then the server is not allowed to query this cvar's value (via IServerPluginHelpers::StartQueryCvarValue). 53 | #define FCVAR_CLIENTCMD_CAN_EXECUTE (1<<30) // IVEngineClient::ClientCmd is allowed to execute this command. 54 | //#define FCVAR_AVAILABLE (1<<31) 55 | 56 | #define FCVAR_MATERIAL_THREAD_MASK ( FCVAR_RELOAD_MATERIALS | FCVAR_RELOAD_TEXTURES | FCVAR_MATERIAL_SYSTEM_THREAD ) 57 | 58 | //----------------------------------------------------------------------------- 59 | // Called when a ConVar changes value 60 | // NOTE: For FCVAR_NEVER_AS_STRING ConVars, pOldValue == NULL 61 | //----------------------------------------------------------------------------- 62 | typedef void(*FnChangeCallback_t)(IConVar *var, const char *pOldValue, float flOldValue); 63 | 64 | 65 | //----------------------------------------------------------------------------- 66 | // Abstract interface for ConVars 67 | //----------------------------------------------------------------------------- 68 | class IConVar 69 | { 70 | public: 71 | virtual void SetValue(const char *pValue) = 0; 72 | virtual void SetValue(float flValue) = 0; 73 | virtual void SetValue(int nValue) = 0; 74 | virtual void SetValue(Color value) = 0; 75 | virtual const char* GetName(void) const = 0; 76 | virtual const char* GetBaseName(void) const = 0; 77 | virtual bool IsFlagSet(int nFlag) const = 0; 78 | virtual int GetSplitScreenPlayerSlot() const = 0; 79 | }; -------------------------------------------------------------------------------- /src/SDK/IEngineTrace.cpp: -------------------------------------------------------------------------------- 1 | #include "IEngineTrace.h" -------------------------------------------------------------------------------- /src/SDK/IEngineTrace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sdk.h" 4 | 5 | #define MASK_ALL (0xFFFFFFFF) 6 | 7 | struct Ray_t 8 | { 9 | __declspec(align(16)) Vector m_Start; 10 | __declspec(align(16)) Vector m_Delta; 11 | __declspec(align(16)) Vector m_StartOffset; 12 | __declspec(align(16)) Vector m_Extents; 13 | //without your matrix3x4 14 | bool m_IsRay; 15 | bool m_IsSwept; 16 | 17 | void Init(Vector const& start, Vector const& end) 18 | { 19 | m_Delta = end - start; 20 | 21 | m_IsSwept = (m_Delta.LengthSqr() != 0); 22 | 23 | m_Extents.x = m_Extents.y = m_Extents.z = 0.0f; 24 | 25 | m_IsRay = true; 26 | 27 | m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f; 28 | 29 | m_Start = start; 30 | } 31 | }; 32 | 33 | class CBaseTrace 34 | { 35 | public: 36 | Vector startpos; 37 | Vector endpos; 38 | cplane_t plane; 39 | float fraction; 40 | int contents; 41 | unsigned short dispFlags; 42 | bool allsolid; 43 | bool startsolid; 44 | }; 45 | 46 | struct csurface_t 47 | { 48 | const char* name; 49 | short surfaceProps; 50 | unsigned short flags; 51 | }; 52 | 53 | class CGameTrace : public CBaseTrace 54 | { 55 | public: 56 | 57 | // Returns true if hEnt points at the world entity. 58 | // If this returns true, then you can't use GetHitBoxIndex(). 59 | bool DidHitWorld() const; 60 | 61 | // Returns true if we hit something and it wasn't the world. 62 | bool DidHitNonWorldEntity() const; 63 | 64 | // Gets the entity's network index if the trace has hit an entity. 65 | // If not, returns -1. 66 | int GetEntityIndex() const; 67 | 68 | // Returns true if there was any kind of impact at all 69 | bool DidHit() const; 70 | public: 71 | 72 | float fractionleftsolid; // time we left a solid, only valid if we started in solid 73 | csurface_t surface; // surface hit (impact surface) 74 | 75 | int hitgroup; // 0 == generic, non-zero is specific body part 76 | short physicsbone; // physics bone hit by trace in studio 77 | 78 | #if defined( CLIENT_DLL ) 79 | C_BaseEntity *m_pEnt; 80 | #else 81 | IClientEntity *m_pEnt; 82 | #endif 83 | 84 | // NOTE: this member is overloaded. 85 | // If hEnt points at the world entity, then this is the static prop index. 86 | // Otherwise, this is the hitbox index. 87 | int hitbox; // box hit by trace in studio 88 | 89 | CGameTrace() {} 90 | 91 | private: 92 | // No copy constructors allowed 93 | CGameTrace(const CGameTrace& vOther); 94 | }; 95 | 96 | 97 | //----------------------------------------------------------------------------- 98 | // Returns true if there was any kind of impact at all 99 | //----------------------------------------------------------------------------- 100 | inline bool CGameTrace::DidHit() const 101 | { 102 | return fraction < 1 || allsolid || startsolid; 103 | } 104 | 105 | 106 | typedef CGameTrace trace_t; 107 | 108 | enum TraceType_t 109 | { 110 | TRACE_EVERYTHING = 0, 111 | TRACE_WORLD_ONLY, 112 | TRACE_ENTITIES_ONLY, 113 | TRACE_EVERYTHING_FILTER_PROPS, 114 | }; 115 | 116 | class ITraceFilter 117 | { 118 | public: 119 | virtual bool ShouldHitEntity(IClientEntity* pEntity, int contentsMask) = 0; 120 | virtual TraceType_t GetTraceType() const = 0; 121 | }; 122 | 123 | class CTraceFilter : public ITraceFilter 124 | { 125 | public: 126 | bool ShouldHitEntity(IClientEntity* pEntityHandle, int contentsMask) 127 | { 128 | return !(pEntityHandle == pSkip); 129 | } 130 | 131 | TraceType_t GetTraceType() const 132 | { 133 | return TRACE_EVERYTHING; 134 | } 135 | 136 | void* pSkip; 137 | }; 138 | 139 | class CTraceFilterSkipTwoEntities : public ITraceFilter 140 | { 141 | public: 142 | CTraceFilterSkipTwoEntities(void *pPassEnt1, void *pPassEnt2) 143 | { 144 | pSkip1 = pPassEnt1; 145 | pSkip2 = pPassEnt2; 146 | } 147 | 148 | virtual bool ShouldHitEntity(IClientEntity *pEntityHandle, int contentsMask) 149 | { 150 | return !(pEntityHandle == pSkip1 || pEntityHandle == pSkip2); 151 | } 152 | virtual TraceType_t GetTraceType() const 153 | { 154 | return TRACE_EVERYTHING; 155 | } 156 | 157 | void* pSkip1; 158 | void* pSkip2; 159 | }; 160 | 161 | class IEngineTrace 162 | { 163 | public: 164 | int GetPointContents(const Vector &vecAbsPosition, IHandleEntity** ppEntity = NULL) 165 | { 166 | typedef int(__thiscall* fnGetPointContents)(void*, const Vector &, IHandleEntity** ); 167 | return get_vfunc(this, 0)(this, vecAbsPosition, ppEntity); 168 | } 169 | 170 | void ClipRayToEntity(const Ray_t &ray, unsigned int fMask, IHandleEntity *pEnt, trace_t *pTrace) 171 | { 172 | typedef void(__thiscall* ClipRayToEntity_fn)(void*, const Ray_t &ray, unsigned int fMask, IHandleEntity *pEnt, trace_t *pTrace); 173 | get_vfunc(this, 2)(this, ray, fMask, pEnt, pTrace); 174 | } 175 | 176 | void TraceRay(const Ray_t &ray, unsigned int fMask, ITraceFilter* pTraceFilter, trace_t* pTrace) 177 | { 178 | typedef void(__thiscall* fnTraceRay)(void*, const Ray_t&, unsigned int, ITraceFilter*, trace_t*); 179 | get_vfunc(this, 4)(this, ray, fMask, pTraceFilter, pTrace); 180 | } 181 | }; -------------------------------------------------------------------------------- /src/SDK/IGameMovement.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector.h" 4 | #include "imovehelper.h" 5 | 6 | class IMoveHelper; 7 | 8 | class CMoveData 9 | { 10 | public: 11 | char pad[4]; 12 | bool m_bFirstRunOfFunctions : 1; 13 | bool m_bGameCodeMovedPlayer : 1; 14 | 15 | EntityHandle_t m_nPlayerHandle; // edict index on server, client entity handle on client 16 | 17 | int m_nImpulseCommand; // Impulse command issued. 18 | QAngle m_vecViewAngles; // Command view angles (local space) 19 | QAngle m_vecAbsViewAngles; // Command view angles (world space) 20 | int m_nButtons; // Attack buttons. 21 | int m_nOldButtons; // From host_client->oldbuttons; 22 | float m_flForwardMove; 23 | float m_flSideMove; 24 | float m_flUpMove; 25 | 26 | float m_flMaxSpeed; 27 | float m_flClientMaxSpeed; 28 | 29 | // Variables from the player edict (sv_player) or entvars on the client. 30 | // These are copied in here before calling and copied out after calling. 31 | Vector m_vecVelocity; // edict::velocity // Current movement direction. 32 | QAngle m_vecAngles; // edict::angles 33 | QAngle m_vecOldAngles; 34 | 35 | // Output only 36 | float m_outStepHeight; // how much you climbed this move 37 | Vector m_outWishVel; // This is where you tried 38 | Vector m_outJumpVel; // This is your jump velocity 39 | 40 | // Movement constraints (radius 0 means no constraint) 41 | Vector m_vecConstraintCenter; 42 | float m_flConstraintRadius; 43 | float m_flConstraintWidth; 44 | float m_flConstraintSpeedFactor; 45 | private: 46 | Vector m_vecAbsOrigin; // edict::origin 47 | }; 48 | 49 | class IGameMovement 50 | { 51 | public: 52 | virtual ~IGameMovement(void) {} 53 | 54 | // Process the current movement command 55 | virtual void ProcessMovement(IClientEntity *pPlayer, CMoveData *pMove) = 0; 56 | virtual void StartTrackPredictionErrors(IClientEntity *pPlayer) = 0; 57 | virtual void FinishTrackPredictionErrors(IClientEntity *pPlayer) = 0; 58 | virtual void DiffPrint(char const *fmt, ...) = 0; 59 | 60 | // Allows other parts of the engine to find out the normal and ducked player bbox sizes 61 | virtual Vector const& GetPlayerMins(bool ducked) const = 0; 62 | virtual Vector const& GetPlayerMaxs(bool ducked) const = 0; 63 | virtual Vector const& GetPlayerViewOffset(bool ducked) const = 0; 64 | 65 | }; -------------------------------------------------------------------------------- /src/SDK/IVModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class IVModelInfo 4 | { 5 | public: 6 | studiohdr_t* GetStudiomodel(const void* model) 7 | { 8 | typedef studiohdr_t*(__thiscall* GetStudiomodel_t)(void*, const void*); 9 | return get_vfunc(this, 28)(this, model); 10 | } 11 | }; -------------------------------------------------------------------------------- /src/SDK/SDK.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Vector.h" 7 | #include "Vector2D.h" 8 | #include "definitions.h" 9 | #include "IAppSystem.h" 10 | #include "Color.h" 11 | #include "ICVar.h" 12 | #include "IBaseClientDll.h" 13 | #include "CRC.h" 14 | #include "CInput.h" 15 | #include "IClientEntity.h" 16 | #include "IClientEntityList.h" 17 | #include "player_info.h" 18 | #include "VMatrix.h" 19 | #include "IVEngineClient.h" 20 | #include "studio.h" 21 | #include "IVModelInfo.h" 22 | #include "CBaseClientState.h" 23 | #include "characterset.h" 24 | #include "bspflags.h" 25 | #include "IEngineTrace.h" 26 | #include "UtlMemory.h" 27 | #include "UtlBuffer.h" 28 | #include "UtlString.h" 29 | #include "UtlVector.h" 30 | #include "IVDebugOverlay.h" 31 | #include "CGlobalVars.h" 32 | #include "checksum_md5.h" 33 | #include "imovehelper.h" 34 | #include "IGameMovement.h" 35 | #include "iprediction.h" 36 | #include "vphysics_interface.h" 37 | #include "ISurface.h" -------------------------------------------------------------------------------- /src/SDK/UtlBuffer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCookieChaser/CSS-Internal/c8efcc7d7a9a4d16873ca578eaa1d53b6cbb1879/src/SDK/UtlBuffer.cpp -------------------------------------------------------------------------------- /src/SDK/UtlBuffer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCookieChaser/CSS-Internal/c8efcc7d7a9a4d16873ca578eaa1d53b6cbb1879/src/SDK/UtlBuffer.h -------------------------------------------------------------------------------- /src/SDK/UtlString.cpp: -------------------------------------------------------------------------------- 1 | #include "UtlString.h" 2 | #include "Vector.h" 3 | 4 | #include 5 | #include 6 | 7 | //----------------------------------------------------------------------------- 8 | // Base class, containing simple memory management 9 | //----------------------------------------------------------------------------- 10 | 11 | CUtlBinaryBlock::CUtlBinaryBlock(int growSize, int initSize) : m_Memory(growSize, initSize) 12 | { 13 | m_nActualLength = 0; 14 | } 15 | 16 | CUtlBinaryBlock::CUtlBinaryBlock(void* pMemory, int nSizeInBytes, int nInitialLength) : m_Memory((unsigned char*)pMemory, nSizeInBytes) 17 | { 18 | m_nActualLength = nInitialLength; 19 | } 20 | 21 | CUtlBinaryBlock::CUtlBinaryBlock(const void* pMemory, int nSizeInBytes) : m_Memory((const unsigned char*)pMemory, nSizeInBytes) 22 | { 23 | m_nActualLength = nSizeInBytes; 24 | } 25 | 26 | CUtlBinaryBlock::CUtlBinaryBlock(const CUtlBinaryBlock& src) 27 | { 28 | Set(src.Get(), src.Length()); 29 | } 30 | 31 | void CUtlBinaryBlock::Get(void *pValue, int nLen) const 32 | { 33 | Assert(nLen > 0); 34 | if (m_nActualLength < nLen) { 35 | nLen = m_nActualLength; 36 | } 37 | 38 | if (nLen > 0) { 39 | memcpy(pValue, m_Memory.Base(), nLen); 40 | } 41 | } 42 | 43 | void CUtlBinaryBlock::SetLength(int nLength) 44 | { 45 | Assert(!m_Memory.IsReadOnly()); 46 | 47 | m_nActualLength = nLength; 48 | if (nLength > m_Memory.NumAllocated()) { 49 | int nOverFlow = nLength - m_Memory.NumAllocated(); 50 | m_Memory.Grow(nOverFlow); 51 | 52 | // If the reallocation failed, clamp length 53 | if (nLength > m_Memory.NumAllocated()) { 54 | m_nActualLength = m_Memory.NumAllocated(); 55 | } 56 | } 57 | 58 | #ifdef _DEBUG 59 | if (m_Memory.NumAllocated() > m_nActualLength) { 60 | memset(((char *)m_Memory.Base()) + m_nActualLength, 0xEB, m_Memory.NumAllocated() - m_nActualLength); 61 | } 62 | #endif 63 | } 64 | 65 | void CUtlBinaryBlock::Set(const void *pValue, int nLen) 66 | { 67 | Assert(!m_Memory.IsReadOnly()); 68 | 69 | if (!pValue) { 70 | nLen = 0; 71 | } 72 | 73 | SetLength(nLen); 74 | 75 | if (m_nActualLength) { 76 | if (((const char *)m_Memory.Base()) >= ((const char *)pValue) + nLen || 77 | ((const char *)m_Memory.Base()) + m_nActualLength <= ((const char *)pValue)) { 78 | memcpy(m_Memory.Base(), pValue, m_nActualLength); 79 | } 80 | else { 81 | memmove(m_Memory.Base(), pValue, m_nActualLength); 82 | } 83 | } 84 | } 85 | 86 | 87 | CUtlBinaryBlock &CUtlBinaryBlock::operator=(const CUtlBinaryBlock &src) 88 | { 89 | Assert(!m_Memory.IsReadOnly()); 90 | Set(src.Get(), src.Length()); 91 | return *this; 92 | } 93 | 94 | 95 | bool CUtlBinaryBlock::operator==(const CUtlBinaryBlock &src) const 96 | { 97 | if (src.Length() != Length()) 98 | return false; 99 | 100 | return !memcmp(src.Get(), Get(), Length()); 101 | } 102 | 103 | 104 | //----------------------------------------------------------------------------- 105 | // Simple string class. 106 | //----------------------------------------------------------------------------- 107 | CUtlString::CUtlString() 108 | { 109 | } 110 | 111 | CUtlString::CUtlString(const char *pString) 112 | { 113 | Set(pString); 114 | } 115 | 116 | CUtlString::CUtlString(const CUtlString& string) 117 | { 118 | Set(string.Get()); 119 | } 120 | 121 | // Attaches the string to external memory. Useful for avoiding a copy 122 | CUtlString::CUtlString(void* pMemory, int nSizeInBytes, int nInitialLength) : m_Storage(pMemory, nSizeInBytes, nInitialLength) 123 | { 124 | } 125 | 126 | CUtlString::CUtlString(const void* pMemory, int nSizeInBytes) : m_Storage(pMemory, nSizeInBytes) 127 | { 128 | } 129 | 130 | void CUtlString::Set(const char *pValue) 131 | { 132 | Assert(!m_Storage.IsReadOnly()); 133 | int nLen = pValue ? strlen(pValue) + 1 : 0; 134 | m_Storage.Set(pValue, nLen); 135 | } 136 | 137 | // Returns strlen 138 | int CUtlString::Length() const 139 | { 140 | return m_Storage.Length() ? m_Storage.Length() - 1 : 0; 141 | } 142 | 143 | // Sets the length (used to serialize into the buffer ) 144 | void CUtlString::SetLength(int nLen) 145 | { 146 | Assert(!m_Storage.IsReadOnly()); 147 | 148 | // Add 1 to account for the NULL 149 | m_Storage.SetLength(nLen > 0 ? nLen + 1 : 0); 150 | } 151 | 152 | const char *CUtlString::Get() const 153 | { 154 | if (m_Storage.Length() == 0) { 155 | return ""; 156 | } 157 | 158 | return reinterpret_cast< const char* >(m_Storage.Get()); 159 | } 160 | 161 | // Converts to c-strings 162 | CUtlString::operator const char*() const 163 | { 164 | return Get(); 165 | } 166 | 167 | char *CUtlString::Get() 168 | { 169 | Assert(!m_Storage.IsReadOnly()); 170 | 171 | if (m_Storage.Length() == 0) { 172 | // In general, we optimise away small mallocs for empty strings 173 | // but if you ask for the non-const bytes, they must be writable 174 | // so we can't return "" here, like we do for the const version - jd 175 | m_Storage.SetLength(1); 176 | m_Storage[0] = '\0'; 177 | } 178 | 179 | return reinterpret_cast< char* >(m_Storage.Get()); 180 | } 181 | 182 | CUtlString &CUtlString::operator=(const CUtlString &src) 183 | { 184 | Assert(!m_Storage.IsReadOnly()); 185 | m_Storage = src.m_Storage; 186 | return *this; 187 | } 188 | 189 | CUtlString &CUtlString::operator=(const char *src) 190 | { 191 | Assert(!m_Storage.IsReadOnly()); 192 | Set(src); 193 | return *this; 194 | } 195 | 196 | bool CUtlString::operator==(const CUtlString &src) const 197 | { 198 | return m_Storage == src.m_Storage; 199 | } 200 | 201 | bool CUtlString::operator==(const char *src) const 202 | { 203 | return (strcmp(Get(), src) == 0); 204 | } 205 | 206 | CUtlString &CUtlString::operator+=(const CUtlString &rhs) 207 | { 208 | Assert(!m_Storage.IsReadOnly()); 209 | 210 | const int lhsLength(Length()); 211 | const int rhsLength(rhs.Length()); 212 | const int requestedLength(lhsLength + rhsLength); 213 | 214 | SetLength(requestedLength); 215 | const int allocatedLength(Length()); 216 | const int copyLength(allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength); 217 | memcpy(Get() + lhsLength, rhs.Get(), copyLength); 218 | m_Storage[allocatedLength] = '\0'; 219 | 220 | return *this; 221 | } 222 | 223 | CUtlString &CUtlString::operator+=(const char *rhs) 224 | { 225 | Assert(!m_Storage.IsReadOnly()); 226 | 227 | const int lhsLength(Length()); 228 | const int rhsLength(strlen(rhs)); 229 | const int requestedLength(lhsLength + rhsLength); 230 | 231 | SetLength(requestedLength); 232 | const int allocatedLength(Length()); 233 | const int copyLength(allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength); 234 | memcpy(Get() + lhsLength, rhs, copyLength); 235 | m_Storage[allocatedLength] = '\0'; 236 | 237 | return *this; 238 | } 239 | 240 | CUtlString &CUtlString::operator+=(char c) 241 | { 242 | Assert(!m_Storage.IsReadOnly()); 243 | 244 | int nLength = Length(); 245 | SetLength(nLength + 1); 246 | m_Storage[nLength] = c; 247 | m_Storage[nLength + 1] = '\0'; 248 | return *this; 249 | } 250 | 251 | CUtlString &CUtlString::operator+=(int rhs) 252 | { 253 | Assert(!m_Storage.IsReadOnly()); 254 | Assert(sizeof(rhs) == 4); 255 | 256 | char tmpBuf[12]; // Sufficient for a signed 32 bit integer [ -2147483648 to +2147483647 ] 257 | snprintf(tmpBuf, sizeof(tmpBuf), "%d", rhs); 258 | tmpBuf[sizeof(tmpBuf) - 1] = '\0'; 259 | 260 | return operator+=(tmpBuf); 261 | } 262 | 263 | CUtlString &CUtlString::operator+=(double rhs) 264 | { 265 | Assert(!m_Storage.IsReadOnly()); 266 | 267 | char tmpBuf[256]; // How big can doubles be??? Dunno. 268 | snprintf(tmpBuf, sizeof(tmpBuf), "%lg", rhs); 269 | tmpBuf[sizeof(tmpBuf) - 1] = '\0'; 270 | 271 | return operator+=(tmpBuf); 272 | } 273 | 274 | int CUtlString::Format(const char *pFormat, ...) 275 | { 276 | Assert(!m_Storage.IsReadOnly()); 277 | 278 | char tmpBuf[4096]; //< Nice big 4k buffer, as much memory as my first computer had, a Radio Shack Color Computer 279 | 280 | va_list marker; 281 | 282 | va_start(marker, pFormat); 283 | int len = _vsnprintf_s(tmpBuf, 4096, sizeof(tmpBuf) - 1, pFormat, marker); 284 | va_end(marker); 285 | 286 | // Len < 0 represents an overflow 287 | if (len < 0) { 288 | len = sizeof(tmpBuf) - 1; 289 | tmpBuf[sizeof(tmpBuf) - 1] = 0; 290 | } 291 | 292 | Set(tmpBuf); 293 | 294 | return len; 295 | } 296 | 297 | //----------------------------------------------------------------------------- 298 | // Strips the trailing slash 299 | //----------------------------------------------------------------------------- 300 | void CUtlString::StripTrailingSlash() 301 | { 302 | if (IsEmpty()) 303 | return; 304 | 305 | int nLastChar = Length() - 1; 306 | char c = m_Storage[nLastChar]; 307 | if (c == '\\' || c == '/') { 308 | m_Storage[nLastChar] = 0; 309 | m_Storage.SetLength(m_Storage.Length() - 1); 310 | } 311 | } -------------------------------------------------------------------------------- /src/SDK/UtlString.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "UtlMemory.h" 7 | 8 | class CUtlBinaryBlock 9 | { 10 | public: 11 | CUtlBinaryBlock(int growSize = 0, int initSize = 0); 12 | 13 | // NOTE: nInitialLength indicates how much of the buffer starts full 14 | CUtlBinaryBlock(void* pMemory, int nSizeInBytes, int nInitialLength); 15 | CUtlBinaryBlock(const void* pMemory, int nSizeInBytes); 16 | CUtlBinaryBlock(const CUtlBinaryBlock& src); 17 | 18 | void Get(void *pValue, int nMaxLen) const; 19 | void Set(const void *pValue, int nLen); 20 | const void* Get() const; 21 | void *Get(); 22 | 23 | unsigned char& operator[](int i); 24 | const unsigned char& operator[](int i) const; 25 | 26 | int Length() const; 27 | void SetLength(int nLength); // Undefined memory will result 28 | bool IsEmpty() const; 29 | void Clear(); 30 | void Purge(); 31 | 32 | bool IsReadOnly() const; 33 | 34 | CUtlBinaryBlock &operator=(const CUtlBinaryBlock &src); 35 | 36 | // Test for equality 37 | bool operator==(const CUtlBinaryBlock &src) const; 38 | 39 | private: 40 | CUtlMemory m_Memory; 41 | int m_nActualLength; 42 | }; 43 | 44 | 45 | //----------------------------------------------------------------------------- 46 | // class inlines 47 | //----------------------------------------------------------------------------- 48 | inline const void *CUtlBinaryBlock::Get() const 49 | { 50 | return m_Memory.Base(); 51 | } 52 | 53 | inline void *CUtlBinaryBlock::Get() 54 | { 55 | return m_Memory.Base(); 56 | } 57 | 58 | inline int CUtlBinaryBlock::Length() const 59 | { 60 | return m_nActualLength; 61 | } 62 | 63 | inline unsigned char& CUtlBinaryBlock::operator[](int i) 64 | { 65 | return m_Memory[i]; 66 | } 67 | 68 | inline const unsigned char& CUtlBinaryBlock::operator[](int i) const 69 | { 70 | return m_Memory[i]; 71 | } 72 | 73 | inline bool CUtlBinaryBlock::IsReadOnly() const 74 | { 75 | return m_Memory.IsReadOnly(); 76 | } 77 | 78 | inline bool CUtlBinaryBlock::IsEmpty() const 79 | { 80 | return Length() == 0; 81 | } 82 | 83 | inline void CUtlBinaryBlock::Clear() 84 | { 85 | SetLength(0); 86 | } 87 | 88 | inline void CUtlBinaryBlock::Purge() 89 | { 90 | SetLength(0); 91 | m_Memory.Purge(); 92 | } 93 | 94 | //----------------------------------------------------------------------------- 95 | // Simple string class. 96 | // NOTE: This is *not* optimal! Use in tools, but not runtime code 97 | //----------------------------------------------------------------------------- 98 | class CUtlString 99 | { 100 | public: 101 | CUtlString(); 102 | CUtlString(const char *pString); 103 | CUtlString(const CUtlString& string); 104 | 105 | // Attaches the string to external memory. Useful for avoiding a copy 106 | CUtlString(void* pMemory, int nSizeInBytes, int nInitialLength); 107 | CUtlString(const void* pMemory, int nSizeInBytes); 108 | 109 | const char *Get() const; 110 | void Set(const char *pValue); 111 | 112 | // Set directly and don't look for a null terminator in pValue. 113 | void SetDirect(const char *pValue, int nChars); 114 | 115 | // Converts to c-strings 116 | operator const char*() const; 117 | 118 | // for compatibility switching items from UtlSymbol 119 | const char *String() const { return Get(); } 120 | 121 | // Returns strlen 122 | int Length() const; 123 | bool IsEmpty() const; 124 | 125 | // Sets the length (used to serialize into the buffer ) 126 | // Note: If nLen != 0, then this adds an extra byte for a null-terminator. 127 | void SetLength(int nLen); 128 | char *Get(); 129 | void Clear(); 130 | void Purge(); 131 | 132 | // Strips the trailing slash 133 | void StripTrailingSlash(); 134 | 135 | CUtlString &operator=(const CUtlString &src); 136 | CUtlString &operator=(const char *src); 137 | 138 | // Test for equality 139 | bool operator==(const CUtlString &src) const; 140 | bool operator==(const char *src) const; 141 | bool operator!=(const CUtlString &src) const { return !operator==(src); } 142 | bool operator!=(const char *src) const { return !operator==(src); } 143 | 144 | CUtlString &operator+=(const CUtlString &rhs); 145 | CUtlString &operator+=(const char *rhs); 146 | CUtlString &operator+=(char c); 147 | CUtlString &operator+=(int rhs); 148 | CUtlString &operator+=(double rhs); 149 | 150 | CUtlString operator+(const char *pOther); 151 | CUtlString operator+(int rhs); 152 | 153 | int Format(const char *pFormat, ...); 154 | 155 | // Take a piece out of the string. 156 | // If you only specify nStart, it'll go from nStart to the end. 157 | // You can use negative numbers and it'll wrap around to the start. 158 | CUtlString Slice(int32_t nStart = 0, int32_t nEnd = INT32_MAX); 159 | 160 | // Grab a substring starting from the left or the right side. 161 | CUtlString Left(int32_t nChars); 162 | CUtlString Right(int32_t nChars); 163 | 164 | // Replace all instances of one character with another. 165 | CUtlString Replace(char cFrom, char cTo); 166 | 167 | // Calls right through to V_MakeAbsolutePath. 168 | CUtlString AbsPath(const char *pStartingDir = NULL); 169 | 170 | // Gets the filename (everything except the path.. c:\a\b\c\somefile.txt -> somefile.txt). 171 | CUtlString UnqualifiedFilename(); 172 | 173 | // Strips off one directory. Uses V_StripLastDir but strips the last slash also! 174 | CUtlString DirName(); 175 | 176 | // Works like V_ComposeFileName. 177 | static CUtlString PathJoin(const char *pStr1, const char *pStr2); 178 | 179 | // These can be used for utlvector sorts. 180 | static int __cdecl SortCaseInsensitive(const CUtlString *pString1, const CUtlString *pString2); 181 | static int __cdecl SortCaseSensitive(const CUtlString *pString1, const CUtlString *pString2); 182 | 183 | private: 184 | CUtlBinaryBlock m_Storage; 185 | }; 186 | 187 | 188 | //----------------------------------------------------------------------------- 189 | // Inline methods 190 | //----------------------------------------------------------------------------- 191 | inline bool CUtlString::IsEmpty() const 192 | { 193 | return Length() == 0; 194 | } 195 | 196 | inline int __cdecl CUtlString::SortCaseInsensitive(const CUtlString *pString1, const CUtlString *pString2) 197 | { 198 | return _stricmp(pString1->String(), pString2->String()); 199 | } 200 | 201 | inline int __cdecl CUtlString::SortCaseSensitive(const CUtlString *pString1, const CUtlString *pString2) 202 | { 203 | return strcmp(pString1->String(), pString2->String()); 204 | } -------------------------------------------------------------------------------- /src/SDK/VMatrix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Vector.h" 6 | 7 | struct cplane_t 8 | { 9 | Vector normal; 10 | float dist; 11 | byte type; // for fast side tests 12 | byte signbits; // signx + (signy<<1) + (signz<<1) 13 | byte pad[2]; 14 | 15 | }; 16 | 17 | class matrix3x4_t 18 | { 19 | public: 20 | matrix3x4_t() {} 21 | matrix3x4_t( 22 | float m00, float m01, float m02, float m03, 23 | float m10, float m11, float m12, float m13, 24 | float m20, float m21, float m22, float m23) 25 | { 26 | m_flMatVal[0][0] = m00; m_flMatVal[0][1] = m01; m_flMatVal[0][2] = m02; m_flMatVal[0][3] = m03; 27 | m_flMatVal[1][0] = m10; m_flMatVal[1][1] = m11; m_flMatVal[1][2] = m12; m_flMatVal[1][3] = m13; 28 | m_flMatVal[2][0] = m20; m_flMatVal[2][1] = m21; m_flMatVal[2][2] = m22; m_flMatVal[2][3] = m23; 29 | } 30 | //----------------------------------------------------------------------------- 31 | // Creates a matrix where the X axis = forward 32 | // the Y axis = left, and the Z axis = up 33 | //----------------------------------------------------------------------------- 34 | void Init(const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin) 35 | { 36 | m_flMatVal[0][0] = xAxis.x; m_flMatVal[0][1] = yAxis.x; m_flMatVal[0][2] = zAxis.x; m_flMatVal[0][3] = vecOrigin.x; 37 | m_flMatVal[1][0] = xAxis.y; m_flMatVal[1][1] = yAxis.y; m_flMatVal[1][2] = zAxis.y; m_flMatVal[1][3] = vecOrigin.y; 38 | m_flMatVal[2][0] = xAxis.z; m_flMatVal[2][1] = yAxis.z; m_flMatVal[2][2] = zAxis.z; m_flMatVal[2][3] = vecOrigin.z; 39 | } 40 | 41 | //----------------------------------------------------------------------------- 42 | // Creates a matrix where the X axis = forward 43 | // the Y axis = left, and the Z axis = up 44 | //----------------------------------------------------------------------------- 45 | matrix3x4_t(const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin) 46 | { 47 | Init(xAxis, yAxis, zAxis, vecOrigin); 48 | } 49 | 50 | inline void SetOrigin(Vector const & p) 51 | { 52 | m_flMatVal[0][3] = p.x; 53 | m_flMatVal[1][3] = p.y; 54 | m_flMatVal[2][3] = p.z; 55 | } 56 | 57 | inline void Invalidate(void) 58 | { 59 | for (int i = 0; i < 3; i++) { 60 | for (int j = 0; j < 4; j++) { 61 | m_flMatVal[i][j] = std::numeric_limits::infinity();; 62 | } 63 | } 64 | } 65 | 66 | float *operator[](int i) { return m_flMatVal[i]; } 67 | const float *operator[](int i) const { return m_flMatVal[i]; } 68 | float *Base() { return &m_flMatVal[0][0]; } 69 | const float *Base() const { return &m_flMatVal[0][0]; } 70 | 71 | float m_flMatVal[3][4]; 72 | }; 73 | class VMatrix 74 | { 75 | public: 76 | 77 | VMatrix(); 78 | VMatrix( 79 | vec_t m00, vec_t m01, vec_t m02, vec_t m03, 80 | vec_t m10, vec_t m11, vec_t m12, vec_t m13, 81 | vec_t m20, vec_t m21, vec_t m22, vec_t m23, 82 | vec_t m30, vec_t m31, vec_t m32, vec_t m33 83 | ); 84 | 85 | // Creates a matrix where the X axis = forward 86 | // the Y axis = left, and the Z axis = up 87 | VMatrix(const Vector& forward, const Vector& left, const Vector& up); 88 | 89 | // Construct from a 3x4 matrix 90 | VMatrix(const matrix3x4_t& matrix3x4); 91 | 92 | // Set the values in the matrix. 93 | void Init( 94 | vec_t m00, vec_t m01, vec_t m02, vec_t m03, 95 | vec_t m10, vec_t m11, vec_t m12, vec_t m13, 96 | vec_t m20, vec_t m21, vec_t m22, vec_t m23, 97 | vec_t m30, vec_t m31, vec_t m32, vec_t m33 98 | ); 99 | 100 | 101 | // Initialize from a 3x4 102 | void Init(const matrix3x4_t& matrix3x4); 103 | 104 | // array access 105 | inline float* operator[](int i) 106 | { 107 | return m[i]; 108 | } 109 | 110 | inline const float* operator[](int i) const 111 | { 112 | return m[i]; 113 | } 114 | 115 | // Get a pointer to m[0][0] 116 | inline float *Base() 117 | { 118 | return &m[0][0]; 119 | } 120 | 121 | inline const float *Base() const 122 | { 123 | return &m[0][0]; 124 | } 125 | 126 | void SetLeft(const Vector &vLeft); 127 | void SetUp(const Vector &vUp); 128 | void SetForward(const Vector &vForward); 129 | 130 | void GetBasisVectors(Vector &vForward, Vector &vLeft, Vector &vUp) const; 131 | void SetBasisVectors(const Vector &vForward, const Vector &vLeft, const Vector &vUp); 132 | 133 | // Get/set the translation. 134 | Vector & GetTranslation(Vector &vTrans) const; 135 | void SetTranslation(const Vector &vTrans); 136 | 137 | void PreTranslate(const Vector &vTrans); 138 | void PostTranslate(const Vector &vTrans); 139 | 140 | matrix3x4_t& As3x4(); 141 | const matrix3x4_t& As3x4() const; 142 | void CopyFrom3x4(const matrix3x4_t &m3x4); 143 | void Set3x4(matrix3x4_t& matrix3x4) const; 144 | 145 | bool operator==(const VMatrix& src) const; 146 | bool operator!=(const VMatrix& src) const { return !(*this == src); } 147 | 148 | // Access the basis vectors. 149 | Vector GetLeft() const; 150 | Vector GetUp() const; 151 | Vector GetForward() const; 152 | Vector GetTranslation() const; 153 | 154 | 155 | // Matrix->vector operations. 156 | public: 157 | // Multiply by a 3D vector (same as operator*). 158 | void V3Mul(const Vector &vIn, Vector &vOut) const; 159 | 160 | // Multiply by a 4D vector. 161 | //void V4Mul( const Vector4D &vIn, Vector4D &vOut ) const; 162 | 163 | // Applies the rotation (ignores translation in the matrix). (This just calls VMul3x3). 164 | Vector ApplyRotation(const Vector &vVec) const; 165 | 166 | // Multiply by a vector (divides by w, assumes input w is 1). 167 | Vector operator*(const Vector &vVec) const; 168 | 169 | // Multiply by the upper 3x3 part of the matrix (ie: only apply rotation). 170 | Vector VMul3x3(const Vector &vVec) const; 171 | 172 | // Apply the inverse (transposed) rotation (only works on pure rotation matrix) 173 | Vector VMul3x3Transpose(const Vector &vVec) const; 174 | 175 | // Multiply by the upper 3 rows. 176 | Vector VMul4x3(const Vector &vVec) const; 177 | 178 | // Apply the inverse (transposed) transformation (only works on pure rotation/translation) 179 | Vector VMul4x3Transpose(const Vector &vVec) const; 180 | 181 | 182 | // Matrix->plane operations. 183 | //public: 184 | // Transform the plane. The matrix can only contain translation and rotation. 185 | //void TransformPlane( const VPlane &inPlane, VPlane &outPlane ) const; 186 | 187 | // Just calls TransformPlane and returns the result. 188 | //VPlane operator*(const VPlane &thePlane) const; 189 | 190 | // Matrix->matrix operations. 191 | public: 192 | 193 | VMatrix& operator=(const VMatrix &mOther); 194 | 195 | // Multiply two matrices (out = this * vm). 196 | void MatrixMul(const VMatrix &vm, VMatrix &out) const; 197 | 198 | // Add two matrices. 199 | const VMatrix& operator+=(const VMatrix &other); 200 | 201 | // Just calls MatrixMul and returns the result. 202 | VMatrix operator*(const VMatrix &mOther) const; 203 | 204 | // Add/Subtract two matrices. 205 | VMatrix operator+(const VMatrix &other) const; 206 | VMatrix operator-(const VMatrix &other) const; 207 | 208 | // Negation. 209 | VMatrix operator-() const; 210 | 211 | // Return inverse matrix. Be careful because the results are undefined 212 | // if the matrix doesn't have an inverse (ie: InverseGeneral returns false). 213 | VMatrix operator~() const; 214 | 215 | // Matrix operations. 216 | public: 217 | // Set to identity. 218 | void Identity(); 219 | 220 | bool IsIdentity() const; 221 | 222 | // Setup a matrix for origin and angles. 223 | void SetupMatrixOrgAngles(const Vector &origin, const Vector &vAngles); 224 | 225 | // General inverse. This may fail so check the return! 226 | bool InverseGeneral(VMatrix &vInverse) const; 227 | 228 | // Does a fast inverse, assuming the matrix only contains translation and rotation. 229 | void InverseTR(VMatrix &mRet) const; 230 | 231 | // Usually used for debug checks. Returns true if the upper 3x3 contains 232 | // unit vectors and they are all orthogonal. 233 | bool IsRotationMatrix() const; 234 | 235 | // This calls the other InverseTR and returns the result. 236 | VMatrix InverseTR() const; 237 | 238 | // Get the scale of the matrix's basis vectors. 239 | Vector GetScale() const; 240 | 241 | // (Fast) multiply by a scaling matrix setup from vScale. 242 | VMatrix Scale(const Vector &vScale); 243 | 244 | // Normalize the basis vectors. 245 | VMatrix NormalizeBasisVectors() const; 246 | 247 | // Transpose. 248 | VMatrix Transpose() const; 249 | 250 | // Transpose upper-left 3x3. 251 | VMatrix Transpose3x3() const; 252 | 253 | public: 254 | // The matrix. 255 | vec_t m[4][4]; 256 | }; -------------------------------------------------------------------------------- /src/SDK/Vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define CHECK_VALID( _v ) 0 7 | #define Assert( _exp ) ((void)0) 8 | 9 | #define FastSqrt(x) (sqrt)(x) 10 | 11 | #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h 12 | 13 | #define M_PI_F ((float)(M_PI)) // Shouldn't collide with anything. 14 | 15 | #define M_PHI 1.61803398874989484820 // golden ratio 16 | 17 | // NJS: Inlined to prevent floats from being autopromoted to doubles, as with the old system. 18 | #ifndef RAD2DEG 19 | #define RAD2DEG( x ) ( (float)(x) * (float)(180.f / M_PI_F) ) 20 | #endif 21 | 22 | #ifndef DEG2RAD 23 | #define DEG2RAD( x ) ( (float)(x) * (float)(M_PI_F / 180.f) ) 24 | #endif 25 | 26 | // MOVEMENT INFO 27 | enum 28 | { 29 | PITCH = 0, // up / down 30 | YAW, // left / right 31 | ROLL // fall over 32 | }; 33 | 34 | typedef float vec_t; 35 | // 3D Vector 36 | class Vector 37 | { 38 | public: 39 | // Members 40 | vec_t x, y, z; 41 | 42 | // Construction/destruction: 43 | Vector(void); 44 | Vector(vec_t X, vec_t Y, vec_t Z); 45 | Vector(vec_t* clr); 46 | 47 | // Initialization 48 | void Init(vec_t ix = 0.0f, vec_t iy = 0.0f, vec_t iz = 0.0f); 49 | // TODO (Ilya): Should there be an init that takes a single float for consistency? 50 | 51 | // Got any nasty NAN's? 52 | bool IsValid() const; 53 | void Invalidate(); 54 | 55 | // array access... 56 | vec_t operator[](int i) const; 57 | vec_t& operator[](int i); 58 | 59 | // Base address... 60 | vec_t* Base(); 61 | vec_t const* Base() const; 62 | 63 | // Initialization methods 64 | void Random(vec_t minVal, vec_t maxVal); 65 | void Zero(); ///< zero out a vector 66 | 67 | // equality 68 | bool operator==(const Vector& v) const; 69 | bool operator!=(const Vector& v) const; 70 | 71 | // arithmetic operations 72 | Vector& operator+=(const Vector& v) 73 | { 74 | x += v.x; y += v.y; z += v.z; 75 | return *this; 76 | } 77 | 78 | Vector& operator-=(const Vector& v) 79 | { 80 | x -= v.x; y -= v.y; z -= v.z; 81 | return *this; 82 | } 83 | 84 | Vector& operator*=(float fl) 85 | { 86 | x *= fl; 87 | y *= fl; 88 | z *= fl; 89 | return *this; 90 | } 91 | 92 | Vector& operator*=(const Vector& v) 93 | { 94 | x *= v.x; 95 | y *= v.y; 96 | z *= v.z; 97 | return *this; 98 | } 99 | 100 | Vector& operator/=(const Vector& v) 101 | { 102 | x /= v.x; 103 | y /= v.y; 104 | z /= v.z; 105 | return *this; 106 | } 107 | 108 | // this ought to be an opcode. 109 | Vector& operator+=(float fl) 110 | { 111 | x += fl; 112 | y += fl; 113 | z += fl; 114 | return *this; 115 | } 116 | 117 | // this ought to be an opcode. 118 | Vector& operator/=(float fl) 119 | { 120 | x /= fl; 121 | y /= fl; 122 | z /= fl; 123 | return *this; 124 | } 125 | Vector& operator-=(float fl) 126 | { 127 | x -= fl; 128 | y -= fl; 129 | z -= fl; 130 | return *this; 131 | } 132 | 133 | // negate the vector components 134 | void Negate(); 135 | 136 | // Get the vector's magnitude. 137 | vec_t Length() const; 138 | 139 | // Get the vector's magnitude squared. 140 | vec_t LengthSqr(void) const 141 | { 142 | return (x*x + y*y + z*z); 143 | } 144 | 145 | // return true if this vector is (0,0,0) within tolerance 146 | bool IsZero(float tolerance = 0.01f) const 147 | { 148 | return (x > -tolerance && x < tolerance && 149 | y > -tolerance && y < tolerance && 150 | z > -tolerance && z < tolerance); 151 | } 152 | 153 | vec_t NormalizeInPlace(); 154 | Vector Normalized() const; 155 | bool IsLengthGreaterThan(float val) const; 156 | bool IsLengthLessThan(float val) const; 157 | 158 | // check if a vector is within the box defined by two other vectors 159 | bool WithinAABox(Vector const &boxmin, Vector const &boxmax); 160 | 161 | // Get the distance from this vector to the other one. 162 | vec_t DistTo(const Vector &vOther) const; 163 | 164 | // Get the distance from this vector to the other one squared. 165 | // NJS: note, VC wasn't inlining it correctly in several deeply nested inlines due to being an 'out of line' . 166 | // may be able to tidy this up after switching to VC7 167 | vec_t DistToSqr(const Vector &vOther) const 168 | { 169 | Vector delta; 170 | 171 | delta.x = x - vOther.x; 172 | delta.y = y - vOther.y; 173 | delta.z = z - vOther.z; 174 | 175 | return delta.LengthSqr(); 176 | } 177 | 178 | // Copy 179 | void CopyToArray(float* rgfl) const; 180 | 181 | // Multiply, add, and assign to this (ie: *this = a + b * scalar). This 182 | // is about 12% faster than the actual vector equation (because it's done per-component 183 | // rather than per-vector). 184 | void MulAdd(const Vector& a, const Vector& b, float scalar); 185 | 186 | // Dot product. 187 | vec_t Dot(const Vector& vOther) const; 188 | 189 | // assignment 190 | Vector& operator=(const Vector &vOther); 191 | 192 | // 2d 193 | vec_t Length2D(void) const 194 | { 195 | return sqrt(x * x + y * y); 196 | } 197 | vec_t Length2DSqr(void) const; 198 | 199 | /// get the component of this vector parallel to some other given vector 200 | Vector ProjectOnto(const Vector& onto); 201 | 202 | // copy constructors 203 | // Vector(const Vector &vOther); 204 | 205 | // arithmetic operations 206 | Vector operator-(void) const; 207 | 208 | Vector operator+(const Vector& v) const; 209 | Vector operator-(const Vector& v) const; 210 | Vector operator*(const Vector& v) const; 211 | Vector operator/(const Vector& v) const; 212 | Vector operator*(float fl) const; 213 | Vector operator/(float fl) const; 214 | 215 | // Cross product between two vectors. 216 | Vector Cross(const Vector &vOther) const; 217 | 218 | // Returns a vector with the min or max in X, Y, and Z. 219 | Vector Min(const Vector &vOther) const; 220 | Vector Max(const Vector &vOther) const; 221 | 222 | //=============================================== 223 | Vector Normalize() 224 | { 225 | if (this->x != this->x) 226 | this->x = 0; 227 | if (this->y != this->y) 228 | this->y = 0; 229 | if (this->z != this->z) 230 | this->z = 0; 231 | 232 | if (this->x > 89.f) 233 | this->x = 89.f; 234 | if (this->x < -89.f) 235 | this->x = -89.f; 236 | 237 | while (this->y > 180) 238 | this->y -= 360; 239 | while (this->y <= -180) 240 | this->y += 360; 241 | 242 | if (this->y > 180.f) 243 | this->y = 180.f; 244 | if (this->y < -180.f) 245 | this->y = -180.f; 246 | 247 | this->z = 0; 248 | 249 | return *this; 250 | } 251 | }; 252 | 253 | void VectorCopy(const Vector& src, Vector& dst); 254 | float VectorLength(const Vector& v); 255 | void VectorLerp(const Vector& src1, const Vector& src2, vec_t t, Vector& dest); 256 | void VectorCrossProduct(const Vector& a, const Vector& b, Vector& result); 257 | vec_t NormalizeVector(Vector& v); 258 | float VectorNormalize(Vector& vec); 259 | FORCEINLINE void VectorMultiply(const Vector& a, vec_t b, Vector& c); 260 | FORCEINLINE void VectorMultiply(const Vector& a, const Vector& b, Vector& c); 261 | inline void VectorScale(const Vector& in, vec_t scale, Vector& result); 262 | 263 | class __declspec(align(16)) VectorAligned : public Vector 264 | { 265 | public: 266 | inline VectorAligned(void) {}; 267 | inline VectorAligned(vec_t X, vec_t Y, vec_t Z) 268 | { 269 | Init(X, Y, Z); 270 | } 271 | 272 | public: 273 | explicit VectorAligned(const Vector &vOther) 274 | { 275 | Init(vOther.x, vOther.y, vOther.z); 276 | } 277 | 278 | VectorAligned& operator=(const Vector &vOther) 279 | { 280 | Init(vOther.x, vOther.y, vOther.z); 281 | return *this; 282 | } 283 | 284 | float w; 285 | }; 286 | 287 | typedef Vector QAngle; -------------------------------------------------------------------------------- /src/SDK/Vector2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "definitions.h" 4 | 5 | typedef float vec_t; 6 | // 2D Vector 7 | class Vector2D 8 | { 9 | public: 10 | // Members 11 | vec_t x, y; 12 | 13 | // Construction/destruction: 14 | Vector2D(void); 15 | Vector2D(vec_t X, vec_t Y); 16 | Vector2D(vec_t* clr); 17 | 18 | Vector2D::Vector2D(const Vector2D &vOther) 19 | { 20 | x = vOther.x; y = vOther.y; 21 | } 22 | 23 | // Initialization 24 | void Init(vec_t ix = 0.0f, vec_t iy = 0.0f); 25 | // TODO (Ilya): Should there be an init that takes a single float for consistency? 26 | 27 | // Got any nasty NAN's? 28 | bool IsValid() const; 29 | void Invalidate(); 30 | 31 | // array access... 32 | vec_t operator[](int i) const; 33 | vec_t& operator[](int i); 34 | 35 | // Base address... 36 | vec_t* Base(); 37 | vec_t const* Base() const; 38 | 39 | // Initialization methods 40 | void Random(vec_t minVal, vec_t maxVal); 41 | void Zero(); ///< zero out a vector 42 | 43 | // equality 44 | bool operator==(const Vector2D& v) const; 45 | bool operator!=(const Vector2D& v) const; 46 | 47 | // arithmetic operations 48 | Vector2D& operator+=(const Vector2D& v) 49 | { 50 | x += v.x; y += v.y; 51 | return *this; 52 | } 53 | 54 | Vector2D& operator-=(const Vector2D& v) 55 | { 56 | x -= v.x; y -= v.y; 57 | return *this; 58 | } 59 | 60 | Vector2D& operator*=(float fl) 61 | { 62 | x *= fl; 63 | y *= fl; 64 | return *this; 65 | } 66 | 67 | Vector2D& operator*=(const Vector2D& v) 68 | { 69 | x *= v.x; 70 | y *= v.y; 71 | return *this; 72 | } 73 | 74 | Vector2D& operator/=(const Vector2D& v) 75 | { 76 | x /= v.x; 77 | y /= v.y; 78 | return *this; 79 | } 80 | 81 | // this ought to be an opcode. 82 | Vector2D& operator+=(float fl) 83 | { 84 | x += fl; 85 | y += fl; 86 | return *this; 87 | } 88 | 89 | // this ought to be an opcode. 90 | Vector2D& operator/=(float fl) 91 | { 92 | x /= fl; 93 | y /= fl; 94 | return *this; 95 | } 96 | Vector2D& operator-=(float fl) 97 | { 98 | x -= fl; 99 | y -= fl; 100 | return *this; 101 | } 102 | 103 | // negate the vector components 104 | void Negate(); 105 | 106 | // Get the vector's magnitude. 107 | vec_t Length() const; 108 | 109 | // Get the vector's magnitude squared. 110 | vec_t LengthSqr(void) const 111 | { 112 | return (x*x + y*y); 113 | } 114 | 115 | // return true if this vector is (0,0,0) within tolerance 116 | bool IsZero(float tolerance = 0.01f) const 117 | { 118 | return (x > -tolerance && x < tolerance && 119 | y > -tolerance && y < tolerance); 120 | } 121 | 122 | vec_t NormalizeInPlace(); 123 | Vector2D Normalized() const; 124 | bool IsLengthGreaterThan(float val) const; 125 | bool IsLengthLessThan(float val) const; 126 | 127 | // check if a vector is within the box defined by two other vectors 128 | bool WithinAABox(Vector2D const &boxmin, Vector2D const &boxmax); 129 | 130 | // Get the distance from this vector to the other one. 131 | vec_t DistTo(const Vector2D &vOther) const; 132 | 133 | // Get the distance from this vector to the other one squared. 134 | // NJS: note, VC wasn't inlining it correctly in several deeply nested inlines due to being an 'out of line' . 135 | // may be able to tidy this up after switching to VC7 136 | vec_t DistToSqr(const Vector2D &vOther) const 137 | { 138 | Vector2D delta; 139 | 140 | delta.x = x - vOther.x; 141 | delta.y = y - vOther.y; 142 | 143 | return delta.LengthSqr(); 144 | } 145 | 146 | // Copy 147 | void CopyToArray(float* rgfl) const; 148 | 149 | // Multiply, add, and assign to this (ie: *this = a + b * scalar). This 150 | // is about 12% faster than the actual vector equation (because it's done per-component 151 | // rather than per-vector). 152 | void MulAdd(const Vector2D& a, const Vector2D& b, float scalar); 153 | 154 | // Dot product. 155 | vec_t Dot(const Vector2D& vOther) const; 156 | 157 | // assignment 158 | Vector2D& operator=(const Vector2D &vOther); 159 | 160 | // 2d 161 | vec_t Length2D(void) const; 162 | vec_t Length2DSqr(void) const; 163 | 164 | /// get the component of this vector parallel to some other given vector 165 | Vector2D ProjectOnto(const Vector2D& onto); 166 | 167 | // copy constructors 168 | // Vector2D(const Vector2D &vOther); 169 | 170 | // arithmetic operations 171 | Vector2D operator-(void) const; 172 | 173 | Vector2D operator+(const Vector2D& v) const; 174 | Vector2D operator-(const Vector2D& v) const; 175 | Vector2D operator*(const Vector2D& v) const; 176 | Vector2D operator/(const Vector2D& v) const; 177 | Vector2D operator*(float fl) const; 178 | Vector2D operator/(float fl) const; 179 | 180 | // Cross product between two vectors. 181 | Vector2D Cross(const Vector2D &vOther) const; 182 | 183 | // Returns a vector with the min or max in X, Y, and Z. 184 | Vector2D Min(const Vector2D &vOther) const; 185 | Vector2D Max(const Vector2D &vOther) const; 186 | }; -------------------------------------------------------------------------------- /src/SDK/Vector4D.cpp: -------------------------------------------------------------------------------- 1 | #include "Vector4D.h" 2 | 3 | #include 4 | #include 5 | 6 | void VectorCopy(const Vector4D& src, Vector4D& dst) 7 | { 8 | dst.x = src.x; 9 | dst.y = src.y; 10 | dst.z = src.z; 11 | dst.w = src.w; 12 | } 13 | void VectorLerp(const Vector4D& src1, const Vector4D& src2, vec_t t, Vector4D& dest) 14 | { 15 | dest.x = src1.x + (src2.x - src1.x) * t; 16 | dest.y = src1.y + (src2.y - src1.y) * t; 17 | dest.z = src1.z + (src2.z - src1.z) * t; 18 | dest.w = src1.w + (src2.w - src1.w) * t; 19 | } 20 | float VectorLength(const Vector4D& v) 21 | { 22 | return sqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w); 23 | } 24 | 25 | vec_t NormalizeVector(Vector4D& v) 26 | { 27 | vec_t l = v.Length(); 28 | if (l != 0.0f) { 29 | v /= l; 30 | } 31 | else { 32 | v.x = v.y = v.z = v.w = 0.0f; 33 | } 34 | return l; 35 | } 36 | 37 | Vector4D::Vector4D(void) 38 | { 39 | Invalidate(); 40 | } 41 | Vector4D::Vector4D(vec_t X, vec_t Y, vec_t Z, vec_t W) 42 | { 43 | x = X; 44 | y = Y; 45 | z = Z; 46 | w = W; 47 | } 48 | Vector4D::Vector4D(vec_t* clr) 49 | { 50 | x = clr[0]; 51 | y = clr[1]; 52 | z = clr[2]; 53 | w = clr[3]; 54 | } 55 | 56 | //----------------------------------------------------------------------------- 57 | // initialization 58 | //----------------------------------------------------------------------------- 59 | 60 | void Vector4D::Init(vec_t ix, vec_t iy, vec_t iz, vec_t iw) 61 | { 62 | x = ix; y = iy; z = iz; w = iw; 63 | } 64 | 65 | void Vector4D::Random(vec_t minVal, vec_t maxVal) 66 | { 67 | x = minVal + ((float)rand() / RAND_MAX) * (maxVal - minVal); 68 | y = minVal + ((float)rand() / RAND_MAX) * (maxVal - minVal); 69 | z = minVal + ((float)rand() / RAND_MAX) * (maxVal - minVal); 70 | w = minVal + ((float)rand() / RAND_MAX) * (maxVal - minVal); 71 | } 72 | 73 | // This should really be a single opcode on the PowerPC (move r0 onto the vec reg) 74 | void Vector4D::Zero() 75 | { 76 | x = y = z = w = 0.0f; 77 | } 78 | 79 | //----------------------------------------------------------------------------- 80 | // assignment 81 | //----------------------------------------------------------------------------- 82 | 83 | Vector4D& Vector4D::operator=(const Vector4D &vOther) 84 | { 85 | x = vOther.x; y = vOther.y; z = vOther.z; w = vOther.w; 86 | return *this; 87 | } 88 | 89 | 90 | //----------------------------------------------------------------------------- 91 | // Array access 92 | //----------------------------------------------------------------------------- 93 | vec_t& Vector4D::operator[](int i) 94 | { 95 | return ((vec_t*)this)[i]; 96 | } 97 | 98 | vec_t Vector4D::operator[](int i) const 99 | { 100 | return ((vec_t*)this)[i]; 101 | } 102 | 103 | 104 | //----------------------------------------------------------------------------- 105 | // Base address... 106 | //----------------------------------------------------------------------------- 107 | vec_t* Vector4D::Base() 108 | { 109 | return (vec_t*)this; 110 | } 111 | 112 | vec_t const* Vector4D::Base() const 113 | { 114 | return (vec_t const*)this; 115 | } 116 | 117 | //----------------------------------------------------------------------------- 118 | // IsValid? 119 | //----------------------------------------------------------------------------- 120 | 121 | bool Vector4D::IsValid() const 122 | { 123 | return !isinf(x) && !isinf(y) && !isinf(z) && !isinf(w); 124 | } 125 | 126 | //----------------------------------------------------------------------------- 127 | // Invalidate 128 | //----------------------------------------------------------------------------- 129 | 130 | void Vector4D::Invalidate() 131 | { 132 | //#ifdef _DEBUG 133 | //#ifdef VECTOR_PARANOIA 134 | x = y = z = w = std::numeric_limits::infinity(); 135 | //#endif 136 | //#endif 137 | } 138 | 139 | //----------------------------------------------------------------------------- 140 | // comparison 141 | //----------------------------------------------------------------------------- 142 | 143 | bool Vector4D::operator==(const Vector4D& src) const 144 | { 145 | return (src.x == x) && (src.y == y) && (src.z == z) && (src.w == w); 146 | } 147 | 148 | bool Vector4D::operator!=(const Vector4D& src) const 149 | { 150 | return (src.x != x) || (src.y != y) || (src.z != z) || (src.w != w); 151 | } 152 | 153 | 154 | //----------------------------------------------------------------------------- 155 | // Copy 156 | //----------------------------------------------------------------------------- 157 | void Vector4D::CopyToArray(float* rgfl) const 158 | { 159 | rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; rgfl[3] = w; 160 | } 161 | 162 | //----------------------------------------------------------------------------- 163 | // standard math operations 164 | //----------------------------------------------------------------------------- 165 | // #pragma message("TODO: these should be SSE") 166 | 167 | void Vector4D::Negate() 168 | { 169 | x = -x; y = -y; z = -z; w = -w; 170 | } 171 | 172 | // get the component of this vector parallel to some other given vector 173 | Vector4D Vector4D::ProjectOnto(const Vector4D& onto) 174 | { 175 | return onto * (this->Dot(onto) / (onto.LengthSqr())); 176 | } 177 | 178 | // FIXME: Remove 179 | // For backwards compatability 180 | void Vector4D::MulAdd(const Vector4D& a, const Vector4D& b, float scalar) 181 | { 182 | x = a.x + b.x * scalar; 183 | y = a.y + b.y * scalar; 184 | z = a.z + b.z * scalar; 185 | w = a.w + b.w * scalar; 186 | } 187 | 188 | Vector4D VectorLerp(const Vector4D& src1, const Vector4D& src2, vec_t t) 189 | { 190 | Vector4D result; 191 | VectorLerp(src1, src2, t, result); 192 | return result; 193 | } 194 | 195 | vec_t Vector4D::Dot(const Vector4D& b) const 196 | { 197 | return (x*b.x + y*b.y + z*b.z + w*b.w); 198 | } 199 | void VectorClear(Vector4D& a) 200 | { 201 | a.x = a.y = a.z = a.w = 0.0f; 202 | } 203 | 204 | vec_t Vector4D::Length(void) const 205 | { 206 | return sqrt(x*x + y*y + z*z + w*w); 207 | } 208 | 209 | // check a point against a box 210 | bool Vector4D::WithinAABox(Vector4D const &boxmin, Vector4D const &boxmax) 211 | { 212 | return ( 213 | (x >= boxmin.x) && (x <= boxmax.x) && 214 | (y >= boxmin.y) && (y <= boxmax.y) && 215 | (z >= boxmin.z) && (z <= boxmax.z) && 216 | (w >= boxmin.w) && (w <= boxmax.w) 217 | ); 218 | } 219 | 220 | //----------------------------------------------------------------------------- 221 | // Get the distance from this vector to the other one 222 | //----------------------------------------------------------------------------- 223 | vec_t Vector4D::DistTo(const Vector4D &vOther) const 224 | { 225 | Vector4D delta; 226 | delta = *this - vOther; 227 | return delta.Length(); 228 | } 229 | 230 | //----------------------------------------------------------------------------- 231 | // Returns a vector with the min or max in X, Y, and Z. 232 | //----------------------------------------------------------------------------- 233 | Vector4D Vector4D::Min(const Vector4D &vOther) const 234 | { 235 | return Vector4D(x < vOther.x ? x : vOther.x, 236 | y < vOther.y ? y : vOther.y, 237 | z < vOther.z ? z : vOther.z, 238 | w < vOther.w ? w : vOther.w); 239 | } 240 | 241 | Vector4D Vector4D::Max(const Vector4D &vOther) const 242 | { 243 | return Vector4D(x > vOther.x ? x : vOther.x, 244 | y > vOther.y ? y : vOther.y, 245 | z > vOther.z ? z : vOther.z, 246 | w > vOther.w ? w : vOther.w); 247 | } 248 | 249 | 250 | //----------------------------------------------------------------------------- 251 | // arithmetic operations 252 | //----------------------------------------------------------------------------- 253 | 254 | Vector4D Vector4D::operator-(void) const 255 | { 256 | return Vector4D(-x, -y, -z, -w); 257 | } 258 | 259 | Vector4D Vector4D::operator+(const Vector4D& v) const 260 | { 261 | return Vector4D(x + v.x, y + v.y, z + v.z, w + v.w); 262 | } 263 | 264 | Vector4D Vector4D::operator-(const Vector4D& v) const 265 | { 266 | return Vector4D(x - v.x, y - v.y, z - v.z, w - v.w); 267 | } 268 | 269 | Vector4D Vector4D::operator*(float fl) const 270 | { 271 | return Vector4D(x * fl, y * fl, z * fl, w * fl); 272 | } 273 | 274 | Vector4D Vector4D::operator*(const Vector4D& v) const 275 | { 276 | return Vector4D(x * v.x, y * v.y, z * v.z, w * v.w); 277 | } 278 | 279 | Vector4D Vector4D::operator/(float fl) const 280 | { 281 | return Vector4D(x / fl, y / fl, z / fl, w / fl); 282 | } 283 | 284 | Vector4D Vector4D::operator/(const Vector4D& v) const 285 | { 286 | return Vector4D(x / v.x, y / v.y, z / v.z, w / v.w); 287 | } 288 | 289 | Vector4D operator*(float fl, const Vector4D& v) 290 | { 291 | return v * fl; 292 | } -------------------------------------------------------------------------------- /src/SDK/Vector4D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef float vec_t; 4 | // 3D Vector4D 5 | class Vector4D 6 | { 7 | public: 8 | // Members 9 | vec_t x, y, z, w; 10 | 11 | // Construction/destruction: 12 | Vector4D(void); 13 | Vector4D(vec_t X, vec_t Y, vec_t Z, vec_t W); 14 | Vector4D(vec_t* clr); 15 | 16 | // Initialization 17 | void Init(vec_t ix = 0.0f, vec_t iy = 0.0f, vec_t iz = 0.0f, vec_t iw = 0.0f); 18 | // TODO (Ilya): Should there be an init that takes a single float for consistency? 19 | 20 | // Got any nasty NAN's? 21 | bool IsValid() const; 22 | void Invalidate(); 23 | 24 | // array access... 25 | vec_t operator[](int i) const; 26 | vec_t& operator[](int i); 27 | 28 | // Base address... 29 | vec_t* Base(); 30 | vec_t const* Base() const; 31 | 32 | // Initialization methods 33 | void Random(vec_t minVal, vec_t maxVal); 34 | void Zero(); ///< zero out a vector 35 | 36 | // equality 37 | bool operator==(const Vector4D& v) const; 38 | bool operator!=(const Vector4D& v) const; 39 | 40 | // arithmetic operations 41 | Vector4D& operator+=(const Vector4D& v) 42 | { 43 | x += v.x; y += v.y; z += v.z; w += v.w; 44 | return *this; 45 | } 46 | 47 | Vector4D& operator-=(const Vector4D& v) 48 | { 49 | x -= v.x; y -= v.y; z -= v.z; w -= v.w; 50 | return *this; 51 | } 52 | 53 | Vector4D& operator*=(float fl) 54 | { 55 | x *= fl; 56 | y *= fl; 57 | z *= fl; 58 | w *= fl; 59 | return *this; 60 | } 61 | 62 | Vector4D& operator*=(const Vector4D& v) 63 | { 64 | x *= v.x; 65 | y *= v.y; 66 | z *= v.z; 67 | w *= v.w; 68 | return *this; 69 | } 70 | 71 | Vector4D& operator/=(const Vector4D& v) 72 | { 73 | x /= v.x; 74 | y /= v.y; 75 | z /= v.z; 76 | w /= v.w; 77 | return *this; 78 | } 79 | 80 | // this ought to be an opcode. 81 | Vector4D& operator+=(float fl) 82 | { 83 | x += fl; 84 | y += fl; 85 | z += fl; 86 | w += fl; 87 | return *this; 88 | } 89 | 90 | // this ought to be an opcode. 91 | Vector4D& operator/=(float fl) 92 | { 93 | x /= fl; 94 | y /= fl; 95 | z /= fl; 96 | w /= fl; 97 | return *this; 98 | } 99 | Vector4D& operator-=(float fl) 100 | { 101 | x -= fl; 102 | y -= fl; 103 | z -= fl; 104 | w -= fl; 105 | return *this; 106 | } 107 | 108 | // negate the vector components 109 | void Negate(); 110 | 111 | // Get the vector's magnitude. 112 | vec_t Length() const; 113 | 114 | // Get the vector's magnitude squared. 115 | vec_t LengthSqr(void) const 116 | { 117 | return (x*x + y*y + z*z); 118 | } 119 | 120 | // return true if this vector is (0,0,0) within tolerance 121 | bool IsZero(float tolerance = 0.01f) const 122 | { 123 | return (x > -tolerance && x < tolerance && 124 | y > -tolerance && y < tolerance && 125 | z > -tolerance && z < tolerance && 126 | w > -tolerance && w < tolerance); 127 | } 128 | 129 | vec_t NormalizeInPlace(); 130 | Vector4D Normalized() const; 131 | bool IsLengthGreaterThan(float val) const; 132 | bool IsLengthLessThan(float val) const; 133 | 134 | // check if a vector is within the box defined by two other vectors 135 | bool WithinAABox(Vector4D const &boxmin, Vector4D const &boxmax); 136 | 137 | // Get the distance from this vector to the other one. 138 | vec_t DistTo(const Vector4D &vOther) const; 139 | 140 | // Get the distance from this vector to the other one squared. 141 | // NJS: note, VC wasn't inlining it correctly in several deeply nested inlines due to being an 'out of line' . 142 | // may be able to tidy this up after switching to VC7 143 | vec_t DistToSqr(const Vector4D &vOther) const 144 | { 145 | Vector4D delta; 146 | 147 | delta.x = x - vOther.x; 148 | delta.y = y - vOther.y; 149 | delta.z = z - vOther.z; 150 | delta.w = w - vOther.w; 151 | 152 | return delta.LengthSqr(); 153 | } 154 | 155 | // Copy 156 | void CopyToArray(float* rgfl) const; 157 | 158 | // Multiply, add, and assign to this (ie: *this = a + b * scalar). This 159 | // is about 12% faster than the actual vector equation (because it's done per-component 160 | // rather than per-vector). 161 | void MulAdd(const Vector4D& a, const Vector4D& b, float scalar); 162 | 163 | // Dot product. 164 | vec_t Dot(const Vector4D& vOther) const; 165 | 166 | // assignment 167 | Vector4D& operator=(const Vector4D &vOther); 168 | 169 | // 2d 170 | vec_t Length2D(void) const; 171 | vec_t Length2DSqr(void) const; 172 | 173 | /// get the component of this vector parallel to some other given vector 174 | Vector4D ProjectOnto(const Vector4D& onto); 175 | 176 | // copy constructors 177 | // Vector4D(const Vector4D &vOther); 178 | 179 | // arithmetic operations 180 | Vector4D operator-(void) const; 181 | 182 | Vector4D operator+(const Vector4D& v) const; 183 | Vector4D operator-(const Vector4D& v) const; 184 | Vector4D operator*(const Vector4D& v) const; 185 | Vector4D operator/(const Vector4D& v) const; 186 | Vector4D operator*(float fl) const; 187 | Vector4D operator/(float fl) const; 188 | 189 | // Returns a vector with the min or max in X, Y, and Z. 190 | Vector4D Min(const Vector4D &vOther) const; 191 | Vector4D Max(const Vector4D &vOther) const; 192 | }; -------------------------------------------------------------------------------- /src/SDK/bspflags.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCookieChaser/CSS-Internal/c8efcc7d7a9a4d16873ca578eaa1d53b6cbb1879/src/SDK/bspflags.h -------------------------------------------------------------------------------- /src/SDK/characterset.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCookieChaser/CSS-Internal/c8efcc7d7a9a4d16873ca578eaa1d53b6cbb1879/src/SDK/characterset.cpp -------------------------------------------------------------------------------- /src/SDK/characterset.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCookieChaser/CSS-Internal/c8efcc7d7a9a4d16873ca578eaa1d53b6cbb1879/src/SDK/characterset.h -------------------------------------------------------------------------------- /src/SDK/cmodel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SDK.h" 4 | 5 | struct edict_t; 6 | struct model_t; 7 | 8 | #include "bspflags.h" 9 | 10 | #define AREA_SOLID 1 11 | #define AREA_TRIGGERS 2 12 | 13 | #include "vcollide.h" 14 | 15 | struct cmodel_t 16 | { 17 | Vector mins, maxs; 18 | Vector origin; 19 | int headnode; 20 | 21 | vcollide_t vcollisionData; 22 | }; 23 | 24 | struct csurface_t 25 | { 26 | const char *name; 27 | short surfaceProps; 28 | unsigned short flags; 29 | }; 30 | 31 | struct Ray_t 32 | { 33 | __declspec(align(16)) Vector m_Start; 34 | __declspec(align(16)) Vector m_Delta; 35 | __declspec(align(16)) Vector m_StartOffset; 36 | __declspec(align(16)) Vector m_Extents; 37 | //without your matrix3x4 38 | bool m_IsRay; 39 | bool m_IsSwept; 40 | 41 | void Init(Vector& vecStart, Vector& vecEnd) 42 | { 43 | m_Delta = vecEnd - vecStart; 44 | 45 | m_IsSwept = (m_Delta.LengthSqr() != 0); 46 | 47 | m_Extents.x = m_Extents.y = m_Extents.z = 0.0f; 48 | 49 | m_IsRay = true; 50 | 51 | m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f; 52 | 53 | m_Start = vecStart; 54 | } 55 | }; -------------------------------------------------------------------------------- /src/SDK/gametrace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cmodel.h" 4 | #include "utlvector.h" 5 | #include "trace.h" 6 | #include "cmodel.h" 7 | 8 | class C_BaseEntity; 9 | 10 | //----------------------------------------------------------------------------- 11 | // Purpose: A trace is returned when a box is swept through the world 12 | // NOTE: eventually more of this class should be moved up into the base class!! 13 | //----------------------------------------------------------------------------- 14 | class CGameTrace : public CBaseTrace 15 | { 16 | public: 17 | 18 | // Returns true if hEnt points at the world entity. 19 | // If this returns true, then you can't use GetHitBoxIndex(). 20 | bool DidHitWorld() const; 21 | 22 | // Returns true if we hit something and it wasn't the world. 23 | bool DidHitNonWorldEntity() const; 24 | 25 | // Gets the entity's network index if the trace has hit an entity. 26 | // If not, returns -1. 27 | int GetEntityIndex() const; 28 | 29 | // Returns true if there was any kind of impact at all 30 | bool DidHit() const; 31 | 32 | // The engine doesn't know what a CBaseEntity is, so it has a backdoor to 33 | // let it get at the edict. 34 | #if defined( ENGINE_DLL ) 35 | void SetEdict(edict_t *pEdict); 36 | edict_t* GetEdict() const; 37 | #endif 38 | 39 | 40 | public: 41 | 42 | float fractionleftsolid; // time we left a solid, only valid if we started in solid 43 | csurface_t surface; // surface hit (impact surface) 44 | 45 | int hitgroup; // 0 == generic, non-zero is specific body part 46 | short physicsbone; // physics bone hit by trace in studio 47 | 48 | C_BaseEntity *m_pEnt; 49 | 50 | // NOTE: this member is overloaded. 51 | // If hEnt points at the world entity, then this is the static prop index. 52 | // Otherwise, this is the hitbox index. 53 | int hitbox; // box hit by trace in studio 54 | 55 | CGameTrace() {} 56 | 57 | private: 58 | // No copy constructors allowed 59 | CGameTrace(const CGameTrace& vOther); 60 | }; 61 | 62 | 63 | //----------------------------------------------------------------------------- 64 | // Returns true if there was any kind of impact at all 65 | //----------------------------------------------------------------------------- 66 | inline bool CGameTrace::DidHit() const 67 | { 68 | return fraction < 1 || allsolid || startsolid; 69 | } 70 | 71 | 72 | typedef CGameTrace trace_t; -------------------------------------------------------------------------------- /src/SDK/globalvars_base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CGlobalVarsBase 4 | { 5 | public: 6 | float realtime; 7 | int framecount; 8 | float absoluteframetime; 9 | float curtime; 10 | float frametime; 11 | int maxClients; 12 | int tickcount; 13 | float interval_per_tick; 14 | float interpolation_amount; 15 | int simTicksThisFrame; 16 | int network_protocol; 17 | }; -------------------------------------------------------------------------------- /src/SDK/imovehelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IClientEntity.h" 4 | 5 | enum PLAYER_ANIM; 6 | class IPhysicsSurfaceProps; 7 | class Vector; 8 | struct model_t; 9 | struct cmodel_t; 10 | struct vcollide_t; 11 | class CGameTrace; 12 | enum soundlevel_t; 13 | 14 | enum 15 | { 16 | WL_NotInWater = 0, 17 | WL_Feet, 18 | WL_Waist, 19 | WL_Eyes 20 | }; 21 | 22 | typedef CBaseHandle EntityHandle_t; 23 | 24 | #define INVALID_ENTITY_HANDLE INVALID_EHANDLE_INDEX 25 | 26 | class IMoveHelper 27 | { 28 | public: 29 | // Methods associated with a particular entity 30 | virtual char const* GetName(EntityHandle_t handle) const = 0; 31 | 32 | // Adds the trace result to touch list, if contact is not already in list. 33 | virtual void ResetTouchList(void) = 0; 34 | virtual bool AddToTouched(const CGameTrace& tr, const Vector& impactvelocity) = 0; 35 | virtual void ProcessImpacts(void) = 0; 36 | 37 | // Numbered line printf 38 | virtual void Con_NPrintf(int idx, char const* fmt, ...) = 0; 39 | 40 | // These have separate server vs client impementations 41 | virtual void StartSound(const Vector& origin, int channel, char const* sample, float volume, soundlevel_t soundlevel, int fFlags, int pitch) = 0; 42 | virtual void StartSound(const Vector& origin, const char *soundname) = 0; 43 | virtual void PlaybackEventFull(int flags, int clientindex, unsigned short eventindex, float delay, Vector& origin, Vector& angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2) = 0; 44 | 45 | // Apply falling damage to m_pHostPlayer based on m_pHostPlayer->m_flFallVelocity. 46 | virtual bool PlayerFallingDamage(void) = 0; 47 | 48 | // Apply falling damage to m_pHostPlayer based on m_pHostPlayer->m_flFallVelocity. 49 | virtual void PlayerSetAnimation(PLAYER_ANIM playerAnim) = 0; 50 | 51 | virtual IPhysicsSurfaceProps *GetSurfaceProps(void) = 0; 52 | 53 | virtual bool IsWorldEntity(const CBaseHandle &handle) = 0; 54 | }; -------------------------------------------------------------------------------- /src/SDK/iprediction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector.h" 4 | 5 | class C_BasePlayer; 6 | class IMoveHelper; 7 | class IPrediction 8 | { 9 | public: 10 | virtual ~IPrediction(void) {}; 11 | 12 | virtual void Init(void) = 0; 13 | virtual void Shutdown(void) = 0; 14 | 15 | // Run prediction 16 | virtual void Update 17 | ( 18 | int startframe, // World update ( un-modded ) most recently received 19 | bool validframe, // Is frame data valid 20 | int incoming_acknowledged, // Last command acknowledged to have been run by server (un-modded) 21 | int outgoing_command // Last command (most recent) sent to server (un-modded) 22 | ) = 0; 23 | 24 | // We are about to get a network update from the server. We know the update #, so we can pull any 25 | // data purely predicted on the client side and transfer it to the new from data state. 26 | virtual void PreEntityPacketReceived(int commands_acknowledged, int current_world_update_packet) = 0; 27 | virtual void PostEntityPacketReceived(void) = 0; 28 | virtual void PostNetworkDataReceived(int commands_acknowledged) = 0; 29 | 30 | virtual void OnReceivedUncompressedPacket(void) = 0; 31 | 32 | // The engine needs to be able to access a few predicted values 33 | virtual void GetViewOrigin(Vector& org) = 0; 34 | virtual void SetViewOrigin(Vector& org) = 0; 35 | virtual void GetViewAngles(QAngle& ang) = 0; 36 | virtual void SetViewAngles(QAngle& ang) = 0; 37 | virtual void GetLocalViewAngles(QAngle& ang) = 0; 38 | virtual void SetLocalViewAngles(QAngle& ang) = 0; 39 | 40 | virtual bool InPrediction(void) const = 0; 41 | virtual bool IsFirstTimePredicted(void) const = 0; 42 | virtual int GetIncomingPacketNumber(void) const = 0; 43 | virtual void RunCommand(C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper) = 0; 44 | virtual void SetupMove(C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move) = 0; 45 | virtual void FinishMove(C_BasePlayer *player, CUserCmd *ucmd, CMoveData *move) = 0; 46 | virtual void SetIdealPitch(C_BasePlayer *player, const Vector& origin, const QAngle& angles, const Vector& viewheight) = 0; 47 | }; -------------------------------------------------------------------------------- /src/SDK/player_info.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_PLAYER_NAME_LENGTH 32 4 | #define SIGNED_GUID_LEN 32 5 | 6 | typedef struct player_info_s 7 | { 8 | char szName[128]; 9 | int userid; 10 | int m_nUserID; 11 | char guid[SIGNED_GUID_LEN + 1]; 12 | unsigned int friendsid; 13 | char friendsname[MAX_PLAYER_NAME_LENGTH + 96]; 14 | bool fakeplayer; 15 | bool ishltv; 16 | unsigned int customfiles[4]; 17 | unsigned char filesdownloaded; 18 | } player_info_t; -------------------------------------------------------------------------------- /src/SDK/studio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAXSTUDIOBONES 128 4 | 5 | #define BONE_USED_MASK 0x0007FF00 6 | #define BONE_USED_BY_ANYTHING 0x0007FF00 7 | #define BONE_USED_BY_HITBOX 0x00000100 // bone (or child) is used by a hit box 8 | #define BONE_USED_BY_ATTACHMENT 0x00000200 // bone (or child) is used by an attachment point 9 | #define BONE_USED_BY_VERTEX_MASK 0x0003FC00 10 | #define BONE_USED_BY_VERTEX_LOD0 0x00000400 // bone (or child) is used by the toplevel model via skinned vertex 11 | #define BONE_USED_BY_VERTEX_LOD1 0x00000800 12 | #define BONE_USED_BY_VERTEX_LOD2 0x00001000 13 | #define BONE_USED_BY_VERTEX_LOD3 0x00002000 14 | #define BONE_USED_BY_VERTEX_LOD4 0x00004000 15 | #define BONE_USED_BY_VERTEX_LOD5 0x00008000 16 | #define BONE_USED_BY_VERTEX_LOD6 0x00010000 17 | #define BONE_USED_BY_VERTEX_LOD7 0x00020000 18 | #define BONE_USED_BY_BONE_MERGE 0x00040000 // bone is available for bone merge to occur against it 19 | 20 | struct model_t; 21 | struct mstudiobbox_t 22 | { 23 | int bone; 24 | int group; 25 | Vector bbmin; 26 | Vector bbmax; 27 | int szhitboxnameindex; 28 | int pad00[3]; 29 | float pillradius; 30 | int pad01[4]; 31 | }; 32 | 33 | struct mstudiohitboxset_t 34 | { 35 | int sznameindex; 36 | inline char * const pszName(void) const { return ((char *)this) + sznameindex; } 37 | int numhitboxes; 38 | int hitboxindex; 39 | inline mstudiobbox_t *pHitbox(int i) const { return (mstudiobbox_t*)(((BYTE*)this) + hitboxindex) + i; }; 40 | }; 41 | 42 | struct studiohdr_t 43 | { 44 | BYTE pad00[12]; 45 | char name[64]; 46 | BYTE pad01[80]; 47 | int numbones; 48 | int boneindex; 49 | BYTE pad02[12]; 50 | int hitboxsetindex; 51 | BYTE pad03[228]; 52 | 53 | // Look up hitbox set by index 54 | inline mstudiohitboxset_t *pHitboxSet(int i) const 55 | { 56 | return (mstudiohitboxset_t *)(((BYTE *)this) + hitboxsetindex) + i; 57 | }; 58 | 59 | // Calls through to hitbox to determine size of specified set 60 | inline mstudiobbox_t *pHitbox(int i, int set) const 61 | { 62 | const mstudiohitboxset_t *s = pHitboxSet(set); 63 | if (!s) 64 | return NULL; 65 | 66 | return s->pHitbox(i); 67 | }; 68 | 69 | // Calls through to set to get hitbox count for set 70 | inline int iHitboxCount(int set) const 71 | { 72 | const mstudiohitboxset_t *s = pHitboxSet(set); 73 | if (!s) 74 | return 0; 75 | 76 | return s->numhitboxes; 77 | }; 78 | }; -------------------------------------------------------------------------------- /src/SDK/trace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SDK.h" 4 | 5 | // Note: These flags need to match the bspfile.h DISPTRI_TAG_* flags. 6 | #define DISPSURF_FLAG_SURFACE (1<<0) 7 | #define DISPSURF_FLAG_WALKABLE (1<<1) 8 | #define DISPSURF_FLAG_BUILDABLE (1<<2) 9 | #define DISPSURF_FLAG_SURFPROP1 (1<<3) 10 | #define DISPSURF_FLAG_SURFPROP2 (1<<4) 11 | 12 | //============================================================================= 13 | // Base Trace Structure 14 | // - shared between engine/game dlls and tools (vrad) 15 | //============================================================================= 16 | 17 | class CBaseTrace 18 | { 19 | public: 20 | 21 | // Displacement flags tests. 22 | bool IsDispSurface(void) { return ((dispFlags & DISPSURF_FLAG_SURFACE) != 0); } 23 | bool IsDispSurfaceWalkable(void) { return ((dispFlags & DISPSURF_FLAG_WALKABLE) != 0); } 24 | bool IsDispSurfaceBuildable(void) { return ((dispFlags & DISPSURF_FLAG_BUILDABLE) != 0); } 25 | bool IsDispSurfaceProp1(void) { return ((dispFlags & DISPSURF_FLAG_SURFPROP1) != 0); } 26 | bool IsDispSurfaceProp2(void) { return ((dispFlags & DISPSURF_FLAG_SURFPROP2) != 0); } 27 | 28 | public: 29 | 30 | // these members are aligned!! 31 | Vector startpos; // start position 32 | Vector endpos; // final position 33 | cplane_t plane; // surface normal at impact 34 | 35 | float fraction; // time completed, 1.0 = didn't hit anything 36 | 37 | int contents; // contents on other side of surface hit 38 | unsigned short dispFlags; // displacement flags for marking surfaces with data 39 | 40 | bool allsolid; // if true, plane is not valid 41 | bool startsolid; // if true, the initial point was in a solid area 42 | 43 | CBaseTrace() {} 44 | 45 | private: 46 | // No copy constructors allowed 47 | CBaseTrace(const CBaseTrace& vOther); 48 | }; -------------------------------------------------------------------------------- /src/SDK/vcollide.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CPhysCollide; 4 | 5 | struct vcollide_t 6 | { 7 | unsigned short solidCount : 15; 8 | unsigned short isPacked : 1; 9 | unsigned short descSize; 10 | CPhysCollide **solids; 11 | char *pKeyValues; 12 | }; -------------------------------------------------------------------------------- /src/SDK/vphysics_interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //----------------------------------------------------------------------------- 4 | // Purpose: These properties are defined per-material. This is accessible at 5 | // each triangle in a collision mesh 6 | //----------------------------------------------------------------------------- 7 | struct surfacephysicsparams_t 8 | { 9 | // vphysics physical properties 10 | float friction; 11 | float elasticity; // collision elasticity - used to compute coefficient of restitution 12 | float density; // physical density (in kg / m^3) 13 | float thickness; // material thickness if not solid (sheet materials) in inches 14 | float dampening; 15 | }; 16 | 17 | struct surfaceaudioparams_t 18 | { 19 | // sounds / audio data 20 | float reflectivity; // like elasticity, but how much sound should be reflected by this surface 21 | float hardnessFactor; // like elasticity, but only affects impact sound choices 22 | float roughnessFactor; // like friction, but only affects scrape sound choices 23 | 24 | // audio thresholds 25 | float roughThreshold; // surface roughness > this causes "rough" scrapes, < this causes "smooth" scrapes 26 | float hardThreshold; // surface hardness > this causes "hard" impacts, < this causes "soft" impacts 27 | float hardVelocityThreshold; // collision velocity > this causes "hard" impacts, < this causes "soft" impacts 28 | // NOTE: Hard impacts must meet both hardnessFactor AND velocity thresholds 29 | }; 30 | 31 | struct surfacesoundnames_t 32 | { 33 | unsigned short stepleft; 34 | unsigned short stepright; 35 | 36 | unsigned short impactSoft; 37 | unsigned short impactHard; 38 | 39 | unsigned short scrapeSmooth; 40 | unsigned short scrapeRough; 41 | 42 | unsigned short bulletImpact; 43 | unsigned short rolling; 44 | 45 | unsigned short breakSound; 46 | unsigned short strainSound; 47 | }; 48 | 49 | struct surfacegameprops_t 50 | { 51 | // game movement data 52 | float maxSpeedFactor; // Modulates player max speed when walking on this surface 53 | float jumpFactor; // Indicates how much higher the player should jump when on the surface 54 | // Game-specific data 55 | unsigned short material; 56 | // Indicates whether or not the player is on a ladder. 57 | unsigned char climbable; 58 | unsigned char pad; 59 | }; 60 | 61 | //----------------------------------------------------------------------------- 62 | // Purpose: Each different material has an entry like this 63 | //----------------------------------------------------------------------------- 64 | struct surfacedata_t 65 | { 66 | surfacephysicsparams_t physics; // physics parameters 67 | surfaceaudioparams_t audio; // audio parameters 68 | surfacesoundnames_t sounds; // names of linked sounds 69 | surfacegameprops_t game; // Game data / properties 70 | 71 | 72 | }; 73 | 74 | class IPhysicsSurfaceProps 75 | { 76 | public: 77 | virtual ~IPhysicsSurfaceProps(void) {} 78 | 79 | // parses a text file containing surface prop keys 80 | virtual int ParseSurfaceData(const char *pFilename, const char *pTextfile) = 0; 81 | // current number of entries in the database 82 | virtual int SurfacePropCount(void) = 0; 83 | 84 | virtual int GetSurfaceIndex(const char *pSurfacePropName) = 0; 85 | virtual void GetPhysicsProperties(int surfaceDataIndex, float *density, float *thickness, float *friction, float *elasticity) = 0; 86 | 87 | virtual surfacedata_t *GetSurfaceData(int surfaceDataIndex) = 0; 88 | virtual const char *GetString(unsigned short stringTableIndex) = 0; 89 | 90 | 91 | virtual const char *GetPropName(int surfaceDataIndex) = 0; 92 | 93 | // sets the global index table for world materials 94 | virtual void SetWorldMaterialIndexTable(int *pMapArray, int mapSize) = 0; 95 | 96 | // NOTE: Same as GetPhysicsProperties, but maybe more convenient 97 | virtual void GetPhysicsParameters(int surfaceDataIndex, surfacephysicsparams_t *pParamsOut) = 0; 98 | }; 99 | -------------------------------------------------------------------------------- /src/hacks/aimbot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../hooks/hooks.h" 4 | #include "../tools/entity.h" 5 | #include "../tools/math.h" 6 | #include "../tools/config.h" 7 | 8 | class caimbot 9 | { 10 | public: 11 | void move(CUserCmd * pCmd, bool & sendpacket); 12 | C_CSPlayer* get_best_target(); 13 | }; 14 | 15 | extern caimbot* aimbot; -------------------------------------------------------------------------------- /src/hacks/misc.cpp: -------------------------------------------------------------------------------- 1 | #include "misc.h" 2 | #include "../tools/game.h" 3 | #include "../tools/math.h" 4 | #include "visuals.h" 5 | 6 | cmisc* misc = new cmisc(); 7 | 8 | void triggerbot(CUserCmd* cmd, C_BasePlayer* local_player, int custom_seed = -1) 9 | { 10 | if (config.misc_triggerbot_on_key && !GetAsyncKeyState(config.misc_triggerbot_key)) 11 | return; 12 | 13 | auto weapon = local_player->GetActiveWeapon(); 14 | if (!weapon) 15 | return; 16 | 17 | const auto server_time = local_player->get_tick_base() * g_globals->interval_per_tick; 18 | if (server_time <= weapon->get_next_primary_attack() || server_time <= local_player->get_next_attack()) 19 | return; 20 | 21 | auto weapon_data = weapon->GetWpnData(); 22 | if (!weapon_data) 23 | return; 24 | 25 | weapon->UpdateAccuracyPenalty(); 26 | 27 | auto seed = cmd->random_seed & 0xFF; 28 | if (custom_seed != -1) 29 | seed = custom_seed; 30 | 31 | game::RandomSeed(seed + 1); 32 | 33 | const auto rand1 = game::RandomFloat(0.f, M_PI_F * 2.f); 34 | const auto rand2 = game::RandomFloat(0.f, weapon->GetInaccuracy()); 35 | 36 | const auto v37 = cosf(rand1) * rand2; 37 | const auto v38 = sinf(rand1) * rand2; 38 | 39 | std::array spreads; 40 | 41 | auto vec_start = local_player->get_eye_position(); 42 | auto viewangles = cmd->viewangles; 43 | viewangles -= local_player->get_aim_punch() * 2.f; 44 | 45 | for (auto i = 0; i < weapon_data->m_iBullets; i++) 46 | { 47 | const auto rand3 = game::RandomFloat(0.0, M_PI_F * 2.f); 48 | const auto rand4 = game::RandomFloat(0.0, weapon->GetSpread()); 49 | 50 | spreads[i].x = cosf(rand3) * rand4; 51 | spreads[i].y = sinf(rand3) * rand4; 52 | 53 | const auto final_spread_x = spreads[i].x + v37; 54 | const auto final_spread_y = spreads[i].y + v38; 55 | 56 | Vector forward, right, up; 57 | math::AngleVectors(viewangles, &forward, &right, &up); 58 | 59 | auto vec_dir = forward + (right * final_spread_x) + (up * final_spread_y); 60 | VectorNormalize(vec_dir); 61 | 62 | float flMaxRange = 8000; 63 | 64 | auto vec_end = vec_start + vec_dir * flMaxRange; // max bullet range is 10000 units 65 | 66 | Ray_t ray; 67 | ray.Init(vec_start, vec_end); 68 | 69 | CTraceFilter filter; 70 | filter.pSkip = local_player; 71 | 72 | trace_t tr; 73 | 74 | g_trace->TraceRay(ray, 0x4600400B, &filter, &tr); 75 | 76 | // Check for player hitboxes extending outside their collision bounds 77 | const float rayExtension = 40.0f; 78 | game::UTIL_ClipTraceToPlayers(vec_start, vec_end + vec_dir * rayExtension, 0x4600400B, &filter, &tr); 79 | 80 | if (tr.fraction == 1.0f) 81 | continue; // we didn't hit anything, stop tracing shoot 82 | 83 | auto entity = reinterpret_cast(tr.m_pEnt); 84 | if (!entity || entity->get_life_state() == 1) 85 | continue; 86 | 87 | if (!config.misc_triggerbot_filter[5] && entity->get_team_num() == local_player->get_team_num()) 88 | continue; 89 | 90 | auto can_continue = false; 91 | if (config.misc_triggerbot_filter[0] && tr.hitgroup == HITGROUP_HEAD) 92 | can_continue = true; 93 | if (config.misc_triggerbot_filter[1] && tr.hitgroup == HITGROUP_CHEST) 94 | can_continue = true; 95 | if (config.misc_triggerbot_filter[2] && tr.hitgroup == HITGROUP_STOMACH) 96 | can_continue = true; 97 | if (config.misc_triggerbot_filter[3] && (tr.hitgroup == HITGROUP_LEFTARM || tr.hitgroup == HITGROUP_RIGHTARM)) 98 | can_continue = true; 99 | if (config.misc_triggerbot_filter[4] && (tr.hitgroup == HITGROUP_LEFTLEG || tr.hitgroup == HITGROUP_RIGHTLEG)) 100 | can_continue = true; 101 | 102 | if (!can_continue) 103 | continue; 104 | 105 | if (custom_seed != -1) 106 | { 107 | cmd->random_seed = custom_seed & 0x7FFFFFFF; 108 | 109 | //Generate a command number for the custom seed 110 | unsigned cmd_number = 0; 111 | while ((MD5_PseudoRandom(cmd_number) & 0xFF) != custom_seed) 112 | cmd_number++; 113 | 114 | cmd->command_number = cmd_number; 115 | } 116 | 117 | cmd->buttons |= IN_ATTACK; 118 | 119 | if (config.visuals_enabled) 120 | { 121 | if (config.visuals_triggerbot_hit_point) 122 | g_debugoverlay->AddBoxOverlay(tr.endpos, Vector(-2, -2, -2), Vector(2, 2, 2), cmd->viewangles, 255, 0, 0, 127, 4); 123 | 124 | if (config.visuals_triggerbot_hitbox) 125 | { 126 | static auto DrawClientHitboxes = reinterpret_cast( 127 | tools::find_pattern("client.dll", "55 8B EC 83 EC 60 57")); 128 | DrawClientHitboxes(tr.m_pEnt, 4.f, false); 129 | } 130 | } 131 | } 132 | } 133 | 134 | void cmisc::move(CUserCmd* cmd) 135 | { 136 | auto local_player = reinterpret_cast(g_entitylist->GetClientEntity(g_engine->GetLocalPlayer())); 137 | if (!local_player) 138 | return; 139 | 140 | switch (config.misc_triggerbot) 141 | { 142 | case 1: 143 | triggerbot(cmd, local_player); 144 | break; 145 | case 2: 146 | { 147 | for (auto i = 0; i < 256; i++) 148 | triggerbot(cmd, local_player, i); 149 | break; 150 | } 151 | default: 152 | break; 153 | } 154 | } 155 | 156 | void cmisc::autojump(CUserCmd* cmd) 157 | { 158 | auto local_player = reinterpret_cast(g_entitylist->GetClientEntity(g_engine->GetLocalPlayer())); 159 | if (!local_player) 160 | return; 161 | 162 | if (config.misc_autojump) 163 | { 164 | if (GetAsyncKeyState(VK_SPACE) && !(local_player->get_flags() & FL_ONGROUND)) 165 | cmd->buttons &= ~IN_JUMP; 166 | } 167 | } 168 | 169 | void cmisc::engine_prediction(C_BasePlayer* player, CUserCmd* ucmd) 170 | { 171 | static auto g_pMoveData = *reinterpret_cast( 172 | tools::find_pattern("client.dll", "FF 35 ? ? ? ? 57") + 2); 173 | static auto m_nPredictionRandomSeed = *reinterpret_cast( 174 | tools::find_pattern("client.dll", "A3 ? ? ? ? 5D C3 55 8B EC 8B 45 08") + 1); 175 | static auto m_pPredictionPlayer = *reinterpret_cast( 176 | tools::find_pattern("client.dll", "89 3D ? ? ? ? F3 0F 2A 87") + 2); 177 | 178 | auto player_address = reinterpret_cast(player); 179 | 180 | //Set m_pCurrentCommand 181 | *reinterpret_cast(player_address + 0x101C) = ucmd; 182 | 183 | *m_nPredictionRandomSeed = ucmd->random_seed; 184 | *m_pPredictionPlayer = player; 185 | 186 | if (*reinterpret_cast(reinterpret_cast(g_prediction) + 0xB)) 187 | g_globals->frametime = 0.0; 188 | else 189 | g_globals->frametime = g_globals->interval_per_tick; 190 | 191 | g_gamemovement->StartTrackPredictionErrors(player); 192 | 193 | if (ucmd->weaponselect) 194 | { 195 | printf("ucmd->weaponselect: %d\n", ucmd->weaponselect); 196 | } 197 | 198 | if (ucmd->impulse) 199 | { 200 | //Set m_nImpulse, yes its 4 bytes, not 1, i have no fucking idea why 201 | *reinterpret_cast(player_address + 0x10C4) = ucmd->impulse; 202 | } 203 | 204 | player->UpdateButtonState(ucmd->buttons); 205 | 206 | player->SetLocalViewAngles(ucmd->viewangles); 207 | 208 | //TODO 209 | //if (C_BasePlayer::PhysicsRunThink(player, 0)) 210 | // (*(void(__thiscall **)(int))(*(_DWORD *)player + 0x3F4))(player); 211 | //thinktick = C_BasePlayer::GetNextThinkTick((_DWORD *)player, 0); 212 | //if (thinktick > 0 && thinktick <= *(_DWORD *)(player + 0x10EC)) 213 | //{ 214 | // C_BasePlayer::SetNextThink((_DWORD *)player, -1.0, 0); 215 | // (*(void(__thiscall **)(int))(*(_DWORD *)player + 0x1E4))(player);// C_BasePlayer::Think 216 | //} 217 | 218 | g_prediction->SetupMove(player, ucmd, g_movehelper, g_pMoveData); 219 | g_gamemovement->ProcessMovement(player, g_pMoveData); 220 | g_prediction->FinishMove(player, ucmd, g_pMoveData); 221 | g_gamemovement->FinishTrackPredictionErrors(player); 222 | 223 | //Set m_pCurrentCommand 224 | *reinterpret_cast(player_address + 0x101C) = nullptr; 225 | 226 | *m_nPredictionRandomSeed = -1; 227 | *m_pPredictionPlayer = nullptr; 228 | } -------------------------------------------------------------------------------- /src/hacks/misc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../tools/entity.h" 4 | #include "../tools/config.h" 5 | 6 | class cmisc 7 | { 8 | public: 9 | void move(CUserCmd* cmd); 10 | void autojump(CUserCmd * cmd); 11 | void engine_prediction(C_BasePlayer * player, CUserCmd * ucmd); 12 | }; 13 | 14 | extern cmisc* misc; -------------------------------------------------------------------------------- /src/hacks/visuals.cpp: -------------------------------------------------------------------------------- 1 | #include "visuals.h" 2 | #include "../tools/math.h" 3 | 4 | cvisuals* visuals = new cvisuals(); 5 | 6 | void render_text(int x, int y, Color color, HFont font, const wchar_t * text) 7 | { 8 | g_surface->DrawSetTextPos(x, y); 9 | g_surface->DrawSetTextFont(font); 10 | g_surface->DrawSetTextColor(color); 11 | g_surface->DrawPrintText(text, wcslen(text)); 12 | } 13 | 14 | const char* WeaponIDToAlias(int id) 15 | { 16 | static auto function = reinterpret_cast( 17 | tools::get_rel32(tools::find_pattern("client.dll", "E8 ? ? ? ? 50 FF 75 94"), 1, 5)); 18 | return function(id); 19 | } 20 | 21 | void cvisuals::initialize() 22 | { 23 | courier_new = g_surface->CreateFont(); 24 | g_surface->SetFontGlyphSet(courier_new, "Courier New", 14, 0, 0, 0, ISurface::FONTFLAG_OUTLINE); 25 | 26 | initialized = true; 27 | } 28 | 29 | void cvisuals::render() 30 | { 31 | render_text(10, 10, config.colors_watermark, courier_new, L"CSS-Internal"); 32 | 33 | if (!config.visuals_enabled) 34 | return; 35 | 36 | render_esp(); 37 | render_spread_circle(); 38 | } 39 | 40 | void cvisuals::render_esp() 41 | { 42 | auto local = reinterpret_cast(g_entitylist->GetClientEntity(g_engine->GetLocalPlayer())); 43 | if (!local) 44 | return; 45 | 46 | for (auto i = 0; i < g_entitylist->GetHighestEntityIndex(); i++) 47 | { 48 | auto entity = reinterpret_cast(g_entitylist->GetClientEntity(i)); 49 | if (!entity || entity->IsDormant()) 50 | continue; 51 | 52 | auto client_class = entity->GetClientClass(); 53 | if (!client_class) 54 | continue; 55 | 56 | if (client_class->m_ClassID == CCSPlayer) 57 | render_player(entity); 58 | } 59 | } 60 | 61 | void cvisuals::render_player(C_CSPlayer* player) 62 | { 63 | auto local = reinterpret_cast(g_entitylist->GetClientEntity(g_engine->GetLocalPlayer())); 64 | if (player->get_life_state() == 1 65 | || player->get_team_num() == local->get_team_num() 66 | || player == local) 67 | return; 68 | 69 | player_info_t info; 70 | if (!g_engine->GetPlayerInfo(player->GetIndex(), &info)) 71 | return; 72 | 73 | auto weapon = player->GetActiveWeapon(); 74 | if (!weapon) 75 | return; 76 | 77 | auto weapondata = weapon->GetWpnData(); 78 | if (!weapondata) 79 | return; 80 | 81 | int screen_width, screen_height; 82 | g_engine->GetScreenSize(screen_width, screen_height); 83 | 84 | rect_s rect{}; 85 | if (get_bounding_box(player, rect)) 86 | { 87 | if (config.visuals_box) 88 | { 89 | g_surface->DrawSetColor(get_player_color(player)); 90 | g_surface->DrawOutlinedRect(rect.left, rect.top, rect.right, rect.bottom); 91 | } 92 | 93 | if (config.visuals_health) 94 | { 95 | g_surface->DrawSetColor(get_health_color(player->get_health())); 96 | g_surface->DrawOutlinedRect(rect.left, rect.bottom + 2, 97 | rect.left + (rect.right - rect.left) / 100.f * player->get_health(), rect.bottom + 2); 98 | } 99 | 100 | if (config.visuals_snapline) 101 | { 102 | g_surface->DrawSetColor(255, 255, 255, 255); 103 | g_surface->DrawLine(screen_width / 2.f, screen_height, rect.left + (rect.right - rect.left) / 2.f, rect.bottom); 104 | } 105 | 106 | wchar_t buf[128]; 107 | if (config.visuals_name) 108 | { 109 | if (MultiByteToWideChar(CP_UTF8, 0, info.szName, -1, buf, 128) > 0) 110 | { 111 | int w, h; 112 | g_surface->GetTextSize(courier_new, buf, w, h); 113 | render_text(rect.left + (rect.right - rect.left) / 2.f - (w / 2.f), rect.top - 16, 114 | Color(255, 255, 255, 255), courier_new, buf); 115 | } 116 | } 117 | 118 | if (config.visuals_weapon) 119 | { 120 | auto weapon_name = WeaponIDToAlias(weapon->GetWeaponID()); 121 | if (!weapon_name) 122 | weapon_name = "unknown"; 123 | 124 | if (MultiByteToWideChar(CP_UTF8, 0, weapon_name, -1, buf, 128) > 0) 125 | { 126 | int w, h; 127 | g_surface->GetTextSize(courier_new, buf, w, h); 128 | render_text(rect.left + (rect.right - rect.left) / 2.f - (w / 2.f), rect.bottom + 1, 129 | Color(255, 255, 255, 255), courier_new, buf); 130 | } 131 | } 132 | } 133 | } 134 | 135 | void cvisuals::render_spread_circle() 136 | { 137 | if (!config.visuals_spread_circle) 138 | return; 139 | 140 | auto local_player = reinterpret_cast(g_entitylist->GetClientEntity(g_engine->GetLocalPlayer())); 141 | if (!local_player) 142 | return; 143 | 144 | auto weapon = local_player->GetActiveWeapon(); 145 | if (!weapon) 146 | return; 147 | 148 | const auto accuracy = weapon->GetInaccuracy() * 550.f; //3000 149 | 150 | int screen_w, screen_h; 151 | g_surface->GetScreenSize(screen_w, screen_h); 152 | 153 | g_surface->DrawSetColor(255, 0, 0, 255); 154 | g_surface->DrawOutlinedCircle(screen_w / 2, screen_h / 2, accuracy, 360); 155 | } 156 | 157 | Color cvisuals::get_player_color(C_CSPlayer* pEntity) 158 | { 159 | if (pEntity->get_team_num() == 2) 160 | return entity::is_visible(pEntity, 12) ? config.colors_esp_visible_t : config.colors_esp_t; 161 | if (pEntity->get_team_num() == 3) 162 | return entity::is_visible(pEntity, 12) ? config.colors_esp_visible_ct : config.colors_esp_ct; 163 | 164 | return Color(); 165 | } 166 | 167 | Color cvisuals::get_health_color(int health) 168 | { 169 | health = max(0, min(health, 100)); 170 | 171 | return Color(min((510 * (100 - health)) / 100, 255), min((510 * health) / 100, 255), 0, 255); 172 | } 173 | 174 | bool cvisuals::get_bounding_box(C_BasePlayer* entity, rect_s& rect) 175 | { 176 | matrix3x4_t trans; 177 | math::AngleMatrix(entity->GetRenderAngles(), entity->GetRenderOrigin(), trans); 178 | 179 | Vector min, max; 180 | entity->GetRenderBounds(min, max); 181 | 182 | std::array points 183 | { 184 | Vector(min.x, min.y, min.z), 185 | Vector(min.x, max.y, min.z), 186 | Vector(max.x, max.y, min.z), 187 | Vector(max.x, min.y, min.z), 188 | Vector(max.x, max.y, max.z), 189 | Vector(min.x, max.y, max.z), 190 | Vector(min.x, min.y, max.z), 191 | Vector(max.x, min.y, max.z) 192 | }; 193 | 194 | for (auto& point : points) 195 | { 196 | Vector point_transformed; 197 | math::VectorTransform(point, trans, point_transformed); 198 | if (g_debugoverlay->ScreenPosition(point_transformed, point)) 199 | return false; 200 | } 201 | 202 | auto left = points[0].x; 203 | auto top = points[0].y; 204 | auto right = points[0].x; 205 | auto bottom = points[0].y; 206 | 207 | for (auto i = 0; i < 8; i++) 208 | { 209 | if (left > points[i].x) 210 | left = points[i].x; 211 | if (bottom < points[i].y) 212 | bottom = points[i].y; 213 | if (right < points[i].x) 214 | right = points[i].x; 215 | if (top > points[i].y) 216 | top = points[i].y; 217 | } 218 | 219 | rect = { left, top, right, bottom }; 220 | 221 | return true; 222 | } -------------------------------------------------------------------------------- /src/hacks/visuals.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../tools/entity.h" 4 | #include "../tools/config.h" 5 | 6 | class cvisuals 7 | { 8 | public: 9 | struct rect_s 10 | { 11 | float left, top, right, bottom; 12 | }; 13 | 14 | void initialize(); 15 | bool is_initialized() const { return initialized; } 16 | void render(); 17 | void render_esp(); 18 | void render_player(C_CSPlayer * player); 19 | void render_spread_circle(); 20 | Color get_player_color(C_CSPlayer * pEntity); 21 | Color get_health_color(int health); 22 | bool get_bounding_box(C_BasePlayer * entity, rect_s& rect); 23 | private: 24 | HFont courier_new = 0; 25 | bool initialized = false; 26 | }; 27 | 28 | extern cvisuals* visuals; -------------------------------------------------------------------------------- /src/hooks/CreateMove.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "../tools/entity.h" 3 | #include "../tools/math.h" 4 | #include "../tools/config.h" 5 | #include "../tools/game.h" 6 | #include "../hacks/aimbot.h" 7 | #include "../hacks/visuals.h" 8 | #include "../hacks/misc.h" 9 | 10 | void __stdcall _CreateMove(int sequence_number, float input_sample_frametime, bool active, bool& sendpacket) 11 | { 12 | o_create_move(sequence_number, input_sample_frametime, active); 13 | 14 | auto cmd = &g_input->m_pCommands[sequence_number % MULTIPLAYER_BACKUP]; 15 | auto verified = &g_input->m_pVerifiedCommands[sequence_number % MULTIPLAYER_BACKUP]; 16 | 17 | if (!cmd || !verified) 18 | return; 19 | 20 | auto local_player = reinterpret_cast(g_entitylist->GetClientEntity(g_engine->GetLocalPlayer())); 21 | if (local_player) 22 | { 23 | misc->autojump(cmd); 24 | 25 | misc->engine_prediction(local_player, cmd); 26 | 27 | misc->move(cmd); 28 | aimbot->move(cmd, sendpacket); 29 | } 30 | 31 | verified->m_cmd = *cmd; 32 | verified->m_crc = cmd->GetChecksum(); 33 | } 34 | 35 | void __declspec(naked) __stdcall create_move(int sequence_number, float input_sample_frametime, bool active) 36 | { 37 | __asm 38 | { 39 | LEA EAX, [EBP - 01] 40 | PUSH EAX 41 | PUSH[ESP + 0x10] 42 | PUSH[ESP + 0x10] 43 | PUSH[ESP + 0x10] 44 | CALL _CreateMove 45 | RET 0x0C 46 | } 47 | } -------------------------------------------------------------------------------- /src/hooks/EndScene.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "../tools/config.h" 3 | #include "../menu.h" 4 | 5 | #include 6 | 7 | void initialize_gui(IDirect3DDevice9* vDevice) 8 | { 9 | ImGui::CreateContext(); 10 | ImGui_ImplDX9_Init(hWindow, vDevice); 11 | 12 | auto& style = ImGui::GetStyle(); 13 | 14 | //style.ChildWindowRounding = 3.f; 15 | style.GrabRounding = 0.f; 16 | style.WindowRounding = 0.f; 17 | style.ScrollbarRounding = 3.f; 18 | style.FrameRounding = 3.f; 19 | style.WindowTitleAlign = ImVec2(0.5f, 0.5f); 20 | 21 | style.Colors[ImGuiCol_Text] = ImVec4(0.73f, 0.73f, 0.73f, 1.00f); 22 | style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); 23 | style.Colors[ImGuiCol_WindowBg] = ImVec4(0.26f, 0.26f, 0.26f, 0.95f); 24 | style.Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.28f, 0.28f, 0.28f, 1.00f); 25 | style.Colors[ImGuiCol_PopupBg] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f); 26 | style.Colors[ImGuiCol_Border] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f); 27 | style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f); 28 | style.Colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); 29 | style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); 30 | style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); 31 | style.Colors[ImGuiCol_TitleBg] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 32 | style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 33 | style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 34 | style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f); 35 | style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.21f, 0.21f, 0.21f, 1.00f); 36 | style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 37 | style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 38 | style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 39 | //style.Colors[ImGuiCol_ComboBg] = ImVec4(0.32f, 0.32f, 0.32f, 1.00f); 40 | style.Colors[ImGuiCol_CheckMark] = ImVec4(0.78f, 0.78f, 0.78f, 1.00f); 41 | style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.74f, 0.74f, 0.74f, 1.00f); 42 | style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.74f, 0.74f, 0.74f, 1.00f); 43 | style.Colors[ImGuiCol_Button] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 44 | style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.43f, 0.43f, 0.43f, 1.00f); 45 | style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); 46 | style.Colors[ImGuiCol_Header] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 47 | style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 48 | style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 49 | style.Colors[ImGuiCol_Column] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); 50 | style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); 51 | style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); 52 | style.Colors[ImGuiCol_ResizeGrip] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f); 53 | style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); 54 | style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); 55 | style.Colors[ImGuiCol_CloseButton] = ImVec4(0.59f, 0.59f, 0.59f, 1.00f); 56 | style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); 57 | style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f); 58 | style.Colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); 59 | style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); 60 | style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); 61 | style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); 62 | style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.32f, 0.52f, 0.65f, 1.00f); 63 | style.Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.50f); 64 | } 65 | 66 | HRESULT STDMETHODCALLTYPE end_scene_hooked(IDirect3DDevice9* vDevice) 67 | { 68 | if (was_initialized) 69 | { 70 | ImGui::GetIO().MouseDrawCursor = config.menu_opened; 71 | ImGui_ImplDX9_NewFrame(); 72 | 73 | menu->render(); 74 | 75 | ImGui::Render(); 76 | } 77 | else 78 | { 79 | initialize_gui(vDevice); 80 | was_initialized = true; 81 | } 82 | 83 | return o_end_scene(vDevice); 84 | } -------------------------------------------------------------------------------- /src/hooks/FrameStageNotify.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "../hacks/visuals.h" 3 | 4 | void __fastcall frame_stage_notify(void* thisptr, void*, ClientFrameStage_t curStage) 5 | { 6 | if (curStage == FRAME_RENDER_START) 7 | { 8 | //drawmanager->clear(); 9 | //visuals->render(); 10 | 11 | auto local_player = reinterpret_cast(g_entitylist->GetClientEntity(g_engine->GetLocalPlayer())); 12 | if (local_player) 13 | local_player->get_flash_max_alpha() = config.visuals_no_flash ? 0.f : 255.f; 14 | } 15 | 16 | o_frame_stage_notify(thisptr, curStage); 17 | } -------------------------------------------------------------------------------- /src/hooks/GetUserCmd.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | 3 | CUserCmd* __fastcall get_user_cmd(void* thisptr, void*, int sequence_number) 4 | { 5 | return &g_input->m_pCommands[sequence_number % MULTIPLAYER_BACKUP]; 6 | } -------------------------------------------------------------------------------- /src/hooks/Paint.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "../hacks/visuals.h" 3 | 4 | void __fastcall paint(void* thisptr, void*, PaintMode_t mode) 5 | { 6 | o_paint(thisptr, mode); 7 | 8 | static auto StartDrawing = reinterpret_cast( 9 | tools::get_rel32(tools::find_pattern("vguimatsurface.dll", "E8 ? ? ? ? 8B 06 8D 4D D8"), 1, 5)); 10 | static auto FinishDrawing = reinterpret_cast( 11 | tools::get_rel32(tools::find_pattern("vguimatsurface.dll", "E8 ? ? ? ? C7 45 ? ? ? ? ? 85 F6"), 1, 5)); 12 | 13 | if (mode & PAINT_UIPANELS) 14 | { 15 | StartDrawing(g_surface); 16 | 17 | if (!visuals->is_initialized()) 18 | visuals->initialize(); 19 | 20 | visuals->render(); 21 | 22 | FinishDrawing(g_surface); 23 | } 24 | } -------------------------------------------------------------------------------- /src/hooks/Reset.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include 3 | 4 | HRESULT STDMETHODCALLTYPE reset_hooked(IDirect3DDevice9* vDevice, D3DPRESENT_PARAMETERS* Params) 5 | { 6 | if (!was_initialized) 7 | return o_reset(vDevice, Params); 8 | 9 | ImGui_ImplDX9_InvalidateDeviceObjects(); 10 | 11 | auto ret = o_reset(vDevice, Params); 12 | 13 | ImGui_ImplDX9_CreateDeviceObjects(); 14 | 15 | return ret; 16 | } 17 | -------------------------------------------------------------------------------- /src/hooks/WndProc.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "../tools/config.h" 3 | 4 | bool PressedKeys[256]{ false }; 5 | bool was_initialized = false; 6 | WNDPROC pOldWindowProc = nullptr; 7 | HWND hWindow = nullptr; 8 | 9 | extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM); 10 | 11 | LRESULT STDMETHODCALLTYPE wnd_proc_hooked(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 12 | { 13 | switch (uMsg) 14 | { 15 | case WM_LBUTTONDOWN: 16 | PressedKeys[VK_LBUTTON] = true; 17 | break; 18 | case WM_LBUTTONUP: 19 | PressedKeys[VK_LBUTTON] = false; 20 | break; 21 | case WM_RBUTTONDOWN: 22 | PressedKeys[VK_RBUTTON] = true; 23 | break; 24 | case WM_RBUTTONUP: 25 | PressedKeys[VK_RBUTTON] = false; 26 | break; 27 | case WM_KEYDOWN: 28 | PressedKeys[wParam] = true; 29 | break; 30 | case WM_KEYUP: 31 | PressedKeys[wParam] = false; 32 | break; 33 | default: break; 34 | } 35 | 36 | { 37 | static bool isDown = false; 38 | static bool isClicked = false; 39 | if (PressedKeys[VK_INSERT]) 40 | { 41 | isClicked = false; 42 | isDown = true; 43 | } 44 | else if (!PressedKeys[VK_INSERT] && isDown) 45 | { 46 | isClicked = true; 47 | isDown = false; 48 | } 49 | else 50 | { 51 | isClicked = false; 52 | isDown = false; 53 | } 54 | 55 | if (isClicked) 56 | { 57 | config.menu_opened = !config.menu_opened; 58 | 59 | *(int*)((DWORD)GetModuleHandleA("vguimatsurface.dll") + 0x139CC0) = !config.menu_opened; 60 | } 61 | } 62 | 63 | if (was_initialized && config.menu_opened && ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam)) 64 | return true; 65 | 66 | return CallWindowProc(pOldWindowProc, hWnd, uMsg, wParam, lParam); 67 | } -------------------------------------------------------------------------------- /src/hooks/WriteUsercmdDeltaToBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | 3 | #define MAX_EDICT_BITS 11 4 | #define WEAPON_SUBTYPE_BITS 6 5 | 6 | void ValidateUserCmd(CUserCmd *usercmd, int sequence_number) 7 | { 8 | CRC32_t crc = usercmd->GetChecksum(); 9 | if (crc != g_input->m_pVerifiedCommands[sequence_number % MULTIPLAYER_BACKUP].m_crc) 10 | { 11 | *usercmd = g_input->m_pVerifiedCommands[sequence_number % MULTIPLAYER_BACKUP].m_cmd; 12 | } 13 | } 14 | 15 | CUserCmd* GetUserCmd(int sequence_number) 16 | { 17 | return &g_input->m_pCommands[sequence_number % MULTIPLAYER_BACKUP];; 18 | } 19 | 20 | bool __fastcall write_usercmd_delta_to_buffer(void* thisptr, void*, void* buf, int from, int to, bool isnewcommand) 21 | { 22 | static auto WriteUsercmd = reinterpret_cast( 23 | tools::find_pattern("client.dll", "55 8B EC 8B 45 10 83 EC 08")); 24 | 25 | CUserCmd* t, *f; 26 | CUserCmd nullcmd; 27 | 28 | if (from == -1) 29 | { 30 | f = &nullcmd; 31 | } 32 | else 33 | { 34 | f = GetUserCmd(from); 35 | if (f) 36 | { 37 | ValidateUserCmd(f, from); 38 | } 39 | else 40 | { 41 | // DevMsg( "WARNING! User command delta too old (from %i, to %i)\n", from, to ); 42 | f = &nullcmd; 43 | } 44 | } 45 | 46 | t = GetUserCmd(to); 47 | if (t) 48 | { 49 | ValidateUserCmd(t, to); 50 | } 51 | else 52 | { 53 | t = &nullcmd; 54 | } 55 | 56 | WriteUsercmd(buf, t, f); 57 | 58 | return *reinterpret_cast(reinterpret_cast(buf) + 0x10) == 0; 59 | } -------------------------------------------------------------------------------- /src/hooks/hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | 3 | cvmt_hook* d3ddevice_table = nullptr; 4 | cvmt_hook* client_table = nullptr; 5 | cvmt_hook* input_table = nullptr; 6 | cvmt_hook* enginevgui_table = nullptr; 7 | 8 | Reset_fn o_reset = nullptr; 9 | EndScene_fn o_end_scene = nullptr; 10 | CreateMove_fn o_create_move = nullptr; 11 | FrameStageNotify_fn o_frame_stage_notify = nullptr; 12 | GetUserCmd_fn o_get_user_cmd = nullptr; 13 | Paint_fn o_paint = nullptr; 14 | 15 | void initialize_hooks() 16 | { 17 | hWindow = FindWindowA("Valve001", nullptr); 18 | 19 | pOldWindowProc = reinterpret_cast(SetWindowLongPtr(hWindow, GWLP_WNDPROC, LONG_PTR(wnd_proc_hooked))); 20 | 21 | d3ddevice_table = new cvmt_hook(g_d3ddevice); 22 | o_reset = d3ddevice_table->hook(16, reinterpret_cast(reset_hooked)); 23 | o_end_scene = d3ddevice_table->hook(42, reinterpret_cast(end_scene_hooked)); 24 | 25 | client_table = new cvmt_hook(g_client); 26 | o_create_move = client_table->hook(21, reinterpret_cast(create_move)); 27 | //client_table->hook(23, WriteUsercmdDeltaToBuffer); 28 | o_frame_stage_notify = client_table->hook(35, reinterpret_cast(frame_stage_notify)); 29 | 30 | input_table = new cvmt_hook(g_input); 31 | o_get_user_cmd = input_table->hook(8, reinterpret_cast(get_user_cmd)); 32 | 33 | enginevgui_table = new cvmt_hook(g_enginevgui); 34 | o_paint = enginevgui_table->hook(13, reinterpret_cast(paint)); 35 | } 36 | 37 | void uninitialize_hooks() 38 | { 39 | SetWindowLongPtr(hWindow, GWLP_WNDPROC, LONG_PTR(pOldWindowProc)); 40 | 41 | delete d3ddevice_table; 42 | delete client_table; 43 | delete input_table; 44 | delete enginevgui_table; 45 | } -------------------------------------------------------------------------------- /src/hooks/hooks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../tools/vmt_hook.h" 5 | #include "../interfaces.h" 6 | 7 | #include 8 | 9 | #pragma comment(lib, "d3d9.lib") 10 | #pragma comment(lib, "d3dx9.lib") 11 | 12 | #include 13 | 14 | extern cvmt_hook* d3ddevice_table; 15 | extern cvmt_hook* client_table; 16 | extern cvmt_hook* input_table; 17 | 18 | typedef HRESULT(STDMETHODCALLTYPE* Reset_fn)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*); 19 | typedef HRESULT(STDMETHODCALLTYPE* EndScene_fn)(IDirect3DDevice9*); 20 | typedef void(__stdcall* CreateMove_fn)(int, float, bool); 21 | typedef void(__thiscall* FrameStageNotify_fn)(void*, ClientFrameStage_t); 22 | typedef CUserCmd*(__thiscall* GetUserCmd_fn)(void*, int sequence_number); 23 | typedef void(__thiscall* Paint_fn)(void*, PaintMode_t); 24 | 25 | extern Reset_fn o_reset; 26 | extern EndScene_fn o_end_scene; 27 | extern CreateMove_fn o_create_move; 28 | extern FrameStageNotify_fn o_frame_stage_notify; 29 | extern GetUserCmd_fn o_get_user_cmd; 30 | extern Paint_fn o_paint; 31 | 32 | HRESULT STDMETHODCALLTYPE reset_hooked(IDirect3DDevice9* vDevice, D3DPRESENT_PARAMETERS* Params); 33 | HRESULT STDMETHODCALLTYPE end_scene_hooked(IDirect3DDevice9* vDevice); 34 | LRESULT STDMETHODCALLTYPE wnd_proc_hooked(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 35 | void __stdcall create_move(int sequence_number, float input_sample_frametime, bool active); 36 | bool __fastcall write_usercmd_delta_to_buffer(void* ecx, void* edx, void* buf, int from, int to, bool isnewcommand); 37 | void __fastcall frame_stage_notify(void* thisptr, void*, ClientFrameStage_t curStage); 38 | CUserCmd* __fastcall get_user_cmd(void* thisptr, void*, int sequence_number); 39 | void __fastcall paint(void* thisptr, void*, PaintMode_t mode); 40 | 41 | extern bool PressedKeys[256]; 42 | extern bool was_initialized; 43 | extern WNDPROC pOldWindowProc; 44 | extern HWND hWindow; 45 | 46 | extern void initialize_hooks(); 47 | extern void uninitialize_hooks(); -------------------------------------------------------------------------------- /src/sdk/CGlobalVars.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CGlobalVars 4 | { 5 | public: 6 | float realtime; 7 | int framecount; 8 | float absoluteframetime; 9 | float curtime; 10 | float frametime; 11 | int maxClients; 12 | int tickcount; 13 | float interval_per_tick; 14 | float interpolation_amount; 15 | int simTicksThisFrame; 16 | int network_protocol; 17 | }; -------------------------------------------------------------------------------- /src/sdk/IVDebugOverlay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Vector; 4 | class Color; 5 | 6 | #define NDEBUG_PERSIST_TILL_NEXT_SERVER (0.01023f) 7 | 8 | class OverlayText_t; 9 | 10 | class IVDebugOverlay 11 | { 12 | public: 13 | virtual void AddEntityTextOverlay(int ent_index, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) = 0; 14 | virtual void AddBoxOverlay(const Vector& origin, const Vector& mins, const Vector& max, QAngle const& orientation, int r, int g, int b, int a, float duration) = 0; 15 | virtual void AddTriangleOverlay(const Vector& p1, const Vector& p2, const Vector& p3, int r, int g, int b, int a, bool noDepthTest, float duration) = 0; 16 | virtual void AddLineOverlay(const Vector& origin, const Vector& dest, int r, int g, int b,bool noDepthTest, float duration) = 0; 17 | virtual void AddTextOverlay(const Vector& origin, float duration, const char *format, ...) = 0; 18 | virtual void AddTextOverlay(const Vector& origin, int line_offset, float duration, const char *format, ...) = 0; 19 | virtual void AddScreenTextOverlay(float flXPos, float flYPos,float flDuration, int r, int g, int b, int a, const char *text) = 0; 20 | virtual void AddSweptBoxOverlay(const Vector& start, const Vector& end, const Vector& mins, const Vector& max, const QAngle & angles, int r, int g, int b, int a, float flDuration) = 0; 21 | virtual void AddGridOverlay(const Vector& origin) = 0; 22 | virtual int ScreenPosition(const Vector& point, Vector& screen) = 0; 23 | virtual int ScreenPosition(float flXPos, float flYPos, Vector& screen) = 0; 24 | 25 | virtual OverlayText_t *GetFirst(void) = 0; 26 | virtual OverlayText_t *GetNext(OverlayText_t *current) = 0; 27 | virtual void ClearDeadOverlays(void) = 0; 28 | virtual void ClearAllOverlays() = 0; 29 | 30 | virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, float r, float g, float b, float alpha, const char *format, ...) = 0; 31 | virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) = 0; 32 | 33 | virtual void AddLineOverlayAlpha(const Vector& origin, const Vector& dest, int r, int g, int b, int a, bool noDepthTest, float duration) = 0; 34 | virtual void AddBoxOverlay2(const Vector& origin, const Vector& mins, const Vector& max, QAngle const& orientation, const Color& faceColor, const Color& edgeColor, float duration) = 0; 35 | 36 | private: 37 | inline void AddTextOverlay(const Vector& origin, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) {} /* catch improper use of bad interface. Needed because '0' duration can be resolved by compiler to NULL format string (i.e., compiles but calls wrong function) */ 38 | }; -------------------------------------------------------------------------------- /src/sdk/checksum_md5.cpp: -------------------------------------------------------------------------------- 1 | #include "checksum_md5.h" 2 | #include 3 | #include 4 | 5 | // The four core functions - F1 is optimized somewhat 6 | // #define F1(x, y, z) (x & y | ~x & z) 7 | #define F1(x, y, z) (z ^ (x & (y ^ z))) 8 | #define F2(x, y, z) F1(z, x, y) 9 | #define F3(x, y, z) (x ^ y ^ z) 10 | #define F4(x, y, z) (y ^ (x | ~z)) 11 | 12 | // This is the central step in the MD5 algorithm. 13 | #define MD5STEP(f, w, x, y, z, data, s) \ 14 | ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) 15 | 16 | //----------------------------------------------------------------------------- 17 | // Purpose: The core of the MD5 algorithm, this alters an existing MD5 hash to 18 | // reflect the addition of 16 longwords of new data. MD5Update blocks 19 | // the data and converts bytes into longwords for this routine. 20 | // Input : buf[4] - 21 | // in[16] - 22 | // Output : static void 23 | //----------------------------------------------------------------------------- 24 | static void MD5Transform(unsigned int buf[4], unsigned int const in[16]) 25 | { 26 | register unsigned int a, b, c, d; 27 | 28 | a = buf[0]; 29 | b = buf[1]; 30 | c = buf[2]; 31 | d = buf[3]; 32 | 33 | MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); 34 | MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); 35 | MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); 36 | MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); 37 | MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); 38 | MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); 39 | MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); 40 | MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); 41 | MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); 42 | MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); 43 | MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); 44 | MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); 45 | MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); 46 | MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); 47 | MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); 48 | MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); 49 | 50 | MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); 51 | MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); 52 | MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); 53 | MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); 54 | MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); 55 | MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); 56 | MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); 57 | MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); 58 | MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); 59 | MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); 60 | MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); 61 | MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); 62 | MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); 63 | MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); 64 | MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); 65 | MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); 66 | 67 | MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); 68 | MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); 69 | MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); 70 | MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); 71 | MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); 72 | MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); 73 | MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); 74 | MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); 75 | MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); 76 | MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); 77 | MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); 78 | MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); 79 | MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); 80 | MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); 81 | MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); 82 | MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); 83 | 84 | MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); 85 | MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); 86 | MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); 87 | MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); 88 | MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); 89 | MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); 90 | MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); 91 | MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); 92 | MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); 93 | MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); 94 | MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); 95 | MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); 96 | MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); 97 | MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); 98 | MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); 99 | MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); 100 | 101 | buf[0] += a; 102 | buf[1] += b; 103 | buf[2] += c; 104 | buf[3] += d; 105 | } 106 | 107 | //----------------------------------------------------------------------------- 108 | // Purpose: Start MD5 accumulation. Set bit count to 0 and buffer to mysterious initialization constants. 109 | 110 | // Input : *ctx - 111 | //----------------------------------------------------------------------------- 112 | void MD5Init(MD5Context_t *ctx) 113 | { 114 | ctx->buf[0] = 0x67452301; 115 | ctx->buf[1] = 0xefcdab89; 116 | ctx->buf[2] = 0x98badcfe; 117 | ctx->buf[3] = 0x10325476; 118 | 119 | ctx->bits[0] = 0; 120 | ctx->bits[1] = 0; 121 | } 122 | 123 | //----------------------------------------------------------------------------- 124 | // Purpose: Update context to reflect the concatenation of another buffer full of bytes. 125 | // Input : *ctx - 126 | // *buf - 127 | // len - 128 | //----------------------------------------------------------------------------- 129 | void MD5Update(MD5Context_t *ctx, unsigned char const *buf, unsigned int len) 130 | { 131 | unsigned int t; 132 | 133 | /* Update bitcount */ 134 | 135 | t = ctx->bits[0]; 136 | if ((ctx->bits[0] = t + ((unsigned int)len << 3)) < t) 137 | ctx->bits[1]++; /* Carry from low to high */ 138 | ctx->bits[1] += len >> 29; 139 | 140 | t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ 141 | 142 | /* Handle any leading odd-sized chunks */ 143 | 144 | if (t) 145 | { 146 | unsigned char *p = (unsigned char *)ctx->in + t; 147 | 148 | t = 64 - t; 149 | if (len < t) 150 | { 151 | memcpy(p, buf, len); 152 | return; 153 | } 154 | memcpy(p, buf, t); 155 | //byteReverse(ctx->in, 16); 156 | MD5Transform(ctx->buf, (unsigned int *)ctx->in); 157 | buf += t; 158 | len -= t; 159 | } 160 | /* Process data in 64-byte chunks */ 161 | 162 | while (len >= 64) 163 | { 164 | memcpy(ctx->in, buf, 64); 165 | //byteReverse(ctx->in, 16); 166 | MD5Transform(ctx->buf, (unsigned int *)ctx->in); 167 | buf += 64; 168 | len -= 64; 169 | } 170 | 171 | /* Handle any remaining bytes of data. */ 172 | memcpy(ctx->in, buf, len); 173 | } 174 | 175 | //----------------------------------------------------------------------------- 176 | // Purpose: Final wrapup - pad to 64-byte boundary with the bit pattern 177 | // 1 0* (64-bit count of bits processed, MSB-first) 178 | // Input : digest[MD5_DIGEST_LENGTH] - 179 | // *ctx - 180 | //----------------------------------------------------------------------------- 181 | void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5Context_t *ctx) 182 | { 183 | unsigned count; 184 | unsigned char *p; 185 | 186 | /* Compute number of bytes mod 64 */ 187 | count = (ctx->bits[0] >> 3) & 0x3F; 188 | 189 | /* Set the first char of padding to 0x80. This is safe since there is 190 | always at least one byte free */ 191 | p = ctx->in + count; 192 | *p++ = 0x80; 193 | 194 | /* Bytes of padding needed to make 64 bytes */ 195 | count = 64 - 1 - count; 196 | 197 | /* Pad out to 56 mod 64 */ 198 | if (count < 8) 199 | { 200 | /* Two lots of padding: Pad the first block to 64 bytes */ 201 | memset(p, 0, count); 202 | //byteReverse(ctx->in, 16); 203 | MD5Transform(ctx->buf, (unsigned int *)ctx->in); 204 | 205 | /* Now fill the next block with 56 bytes */ 206 | memset(ctx->in, 0, 56); 207 | } 208 | else 209 | { 210 | /* Pad block to 56 bytes */ 211 | memset(p, 0, count - 8); 212 | } 213 | //byteReverse(ctx->in, 14); 214 | 215 | /* Append length in bits and transform */ 216 | ((unsigned int *)ctx->in)[14] = ctx->bits[0]; 217 | ((unsigned int *)ctx->in)[15] = ctx->bits[1]; 218 | 219 | MD5Transform(ctx->buf, (unsigned int *)ctx->in); 220 | //byteReverse((unsigned char *) ctx->buf, 4); 221 | memcpy(digest, ctx->buf, MD5_DIGEST_LENGTH); 222 | memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ 223 | } 224 | 225 | //----------------------------------------------------------------------------- 226 | // Purpose: generate pseudo random number from a seed number 227 | // Input : seed number 228 | // Output : pseudo random number 229 | //----------------------------------------------------------------------------- 230 | unsigned int MD5_PseudoRandom(unsigned int nSeed) 231 | { 232 | MD5Context_t ctx; 233 | unsigned char digest[MD5_DIGEST_LENGTH]; // The MD5 Hash 234 | 235 | memset(&ctx, 0, sizeof(ctx)); 236 | 237 | MD5Init(&ctx); 238 | MD5Update(&ctx, (unsigned char*)&nSeed, sizeof(nSeed)); 239 | MD5Final(digest, &ctx); 240 | 241 | return *(unsigned int*)(digest + 6); // use 4 middle bytes for random value 242 | } -------------------------------------------------------------------------------- /src/sdk/checksum_md5.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 16 bytes == 128 bit digest 4 | #define MD5_DIGEST_LENGTH 16 5 | #define MD5_BIT_LENGTH ( MD5_DIGEST_LENGTH * sizeof(unsigned char) ) 6 | 7 | // MD5 Hash 8 | typedef struct 9 | { 10 | unsigned int buf[4]; 11 | unsigned int bits[2]; 12 | unsigned char in[64]; 13 | } MD5Context_t; 14 | 15 | void MD5Init(MD5Context_t *context); 16 | void MD5Update(MD5Context_t *context, unsigned char const *buf, unsigned int len); 17 | void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5Context_t *context); 18 | 19 | unsigned int MD5_PseudoRandom(unsigned int nSeed); -------------------------------------------------------------------------------- /src/tools/config.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include 3 | #include 4 | 5 | config_s config; 6 | 7 | BOOL DirectoryExists(LPCTSTR szPath) 8 | { 9 | DWORD dwAttrib = GetFileAttributes(szPath); 10 | 11 | return (dwAttrib != INVALID_FILE_ATTRIBUTES && 12 | (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); 13 | } 14 | 15 | std::vector config_manager::get_configs() 16 | { 17 | if (!DirectoryExists("CSS-Internal")) 18 | CreateDirectory("CSS-Internal", nullptr); 19 | 20 | std::string config_extension = ".JSON"; 21 | std::vector names; 22 | 23 | WIN32_FIND_DATAA find_data; 24 | HANDLE preset_file = FindFirstFileA(("CSS-Internal\\*" + config_extension).c_str(), &find_data); 25 | 26 | if (preset_file != INVALID_HANDLE_VALUE) 27 | { 28 | do 29 | { 30 | if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 31 | continue; 32 | 33 | names.push_back(find_data.cFileName); 34 | } while (FindNextFileA(preset_file, &find_data)); 35 | 36 | FindClose(preset_file); 37 | } 38 | 39 | return names; 40 | } 41 | 42 | void config_manager::load_config(std::string configname) 43 | { 44 | std::ifstream input_file = std::ifstream(("CSS-Internal\\" + configname).c_str()); 45 | 46 | if (!input_file.good()) 47 | return; 48 | 49 | nlohmann::json j; 50 | 51 | try 52 | { 53 | input_file >> j; 54 | } 55 | catch (...) 56 | { 57 | input_file.close(); 58 | return; 59 | } 60 | 61 | config.aimbot_enabled = j.at("aimbot").at("enabled").get(); 62 | config.aimbot_fov = j.at("aimbot").at("fov").get(); 63 | config.aimbot_smooth = j.at("aimbot").at("smooth").get(); 64 | config.aimbot_hitbox = j.at("aimbot").at("hitbox").get(); 65 | config.aimbot_silent = j.at("aimbot").at("silent").get(); 66 | config.aimbot_autofire = j.at("aimbot").at("autofire").get(); 67 | config.aimbot_on_key = j.at("aimbot").at("on_key").get(); 68 | config.aimbot_key = j.at("aimbot").at("key").get(); 69 | 70 | config.visuals_enabled = j.at("visuals").at("enabled").get(); 71 | config.visuals_box = j.at("visuals").at("box").get(); 72 | config.visuals_health = j.at("visuals").at("health").get(); 73 | config.visuals_snapline = j.at("visuals").at("snapline").get(); 74 | config.visuals_name = j.at("visuals").at("name").get(); 75 | config.visuals_weapon = j.at("visuals").at("weapon").get(); 76 | 77 | config.misc_autojump = j.at("misc").at("autojump").get(); 78 | 79 | input_file.close(); 80 | } 81 | 82 | void config_manager::save_config(std::string configname) 83 | { 84 | auto j = nlohmann::json { 85 | { "aimbot", { 86 | { "enabled", config.aimbot_enabled }, 87 | { "fov", config.aimbot_fov }, 88 | { "smooth", config.aimbot_smooth }, 89 | { "hitbox", config.aimbot_hitbox }, 90 | { "silent", config.aimbot_silent }, 91 | { "autofire", config.aimbot_autofire }, 92 | { "on_key", config.aimbot_on_key }, 93 | { "key", config.aimbot_key } 94 | } }, 95 | { "visuals", { 96 | { "enabled", config.visuals_enabled }, 97 | { "box", config.visuals_box }, 98 | { "health", config.visuals_health }, 99 | { "snapline", config.visuals_snapline }, 100 | { "name", config.visuals_name }, 101 | { "weapon", config.visuals_weapon } 102 | } }, 103 | { "misc", { 104 | { "autojump", config.misc_autojump }, 105 | } }, 106 | }; 107 | 108 | std::ofstream o(("CSS-Internal\\" + configname).c_str()); 109 | o << std::setw(4) << j << std::endl; 110 | } 111 | 112 | void config_manager::remove_config(std::string configname) 113 | { 114 | std::remove(("CSS-Internal\\" + configname).c_str()); 115 | } -------------------------------------------------------------------------------- /src/tools/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "../sdk/Color.h" 6 | 7 | struct config_s 8 | { 9 | config_s() {}; 10 | 11 | bool menu_opened = false; 12 | 13 | bool aimbot_enabled = false; 14 | float aimbot_fov = 0; 15 | float aimbot_smooth = 0; 16 | int aimbot_hitbox = 0; 17 | bool aimbot_silent = false; 18 | bool aimbot_psilent = false; 19 | bool aimbot_autofire = false; 20 | bool aimbot_nospread = false; 21 | float aimbot_mindmg = 20; 22 | bool aimbot_on_key = false; 23 | int aimbot_key = 0; 24 | 25 | bool visuals_enabled = false; 26 | bool visuals_box = false; 27 | bool visuals_health = false; 28 | bool visuals_snapline = false; 29 | bool visuals_name = false; 30 | bool visuals_weapon = false; 31 | bool visuals_triggerbot_hitbox = false; 32 | bool visuals_triggerbot_hit_point = false; 33 | bool visuals_spread_circle = false; 34 | bool visuals_no_flash = false; 35 | 36 | bool misc_autojump = false; 37 | int misc_triggerbot = 0; 38 | bool misc_triggerbot_on_key = false; 39 | int misc_triggerbot_key = 0; 40 | bool misc_triggerbot_filter[6]{ false, false, false, false, false, false }; 41 | 42 | Color colors_esp_t = Color(163, 33, 13, 255); 43 | Color colors_esp_ct = Color(0, 84, 181, 255); 44 | Color colors_esp_visible_t = Color(255, 208, 0, 255); 45 | Color colors_esp_visible_ct = Color(91, 219, 0, 255); 46 | Color colors_watermark = Color(0, 255, 0, 255); 47 | }; 48 | 49 | extern config_s config; 50 | 51 | namespace config_manager 52 | { 53 | std::vector get_configs(); 54 | void load_config(std::string configname); 55 | void save_config(std::string configname); 56 | void remove_config(std::string configname); 57 | } -------------------------------------------------------------------------------- /src/tools/entity.cpp: -------------------------------------------------------------------------------- 1 | #include "Entity.h" 2 | #include "Math.h" 3 | #include "game.h" 4 | 5 | Vector entity::get_bone_position(C_CSPlayer* pEntity, int bone) 6 | { 7 | matrix3x4_t boneMatrix[128]; 8 | if (pEntity->SetupBones(boneMatrix, 128, 0x00000100, 0)) 9 | { 10 | return Vector(boneMatrix[bone][0][3], boneMatrix[bone][1][3], boneMatrix[bone][2][3]); 11 | } 12 | return Vector(0, 0, 0); 13 | } 14 | 15 | Vector entity::get_hitbox_position(C_CSPlayer* pEntity, int HitboxID) 16 | { 17 | matrix3x4_t matrix[128]; 18 | if (!pEntity->SetupBones(matrix, 128, 0x00000100, 0)) 19 | return Vector(0, 0, 0); 20 | 21 | auto model = pEntity->GetModel(); 22 | 23 | if (!model) 24 | return Vector(0, 0, 0); 25 | 26 | studiohdr_t* hdr = g_modelinfo->GetStudiomodel(model); 27 | if (!hdr) 28 | return Vector(0, 0, 0); 29 | 30 | mstudiohitboxset_t* set = hdr->pHitboxSet(pEntity->get_hitbox_set()); 31 | if (!set) 32 | return Vector(0, 0, 0); 33 | 34 | mstudiobbox_t* hitbox = set->pHitbox(HitboxID); 35 | if (!hitbox) 36 | return Vector(0, 0, 0); 37 | 38 | Vector vMin, vMax, vCenter, sCenter; 39 | math::VectorTransform(hitbox->bbmin, matrix[hitbox->bone], vMin); 40 | math::VectorTransform(hitbox->bbmax, matrix[hitbox->bone], vMax); 41 | vCenter = (vMin + vMax) * 0.5f; 42 | 43 | return vCenter; 44 | } 45 | 46 | void entity::fix_trace_ray(Vector end, Vector start, trace_t* oldtrace, C_BasePlayer* ent) 47 | { 48 | Vector mins, maxs; 49 | ent->GetRenderBounds(mins, maxs); 50 | 51 | auto CenterOfBBOX = (maxs + mins) * 0.5f; 52 | auto origin = ent->get_origin(); 53 | 54 | Vector CenterOfEntityInWorld = (CenterOfBBOX + origin); 55 | 56 | Vector delta(end - start); 57 | delta.Normalize(); 58 | 59 | auto v20 = (CenterOfEntityInWorld - start); 60 | auto ForwardDot = delta.Dot(v20); 61 | 62 | float v23; 63 | 64 | if (ForwardDot >= 0.0f) 65 | { 66 | //Player is at or in front 67 | if (ForwardDot <= delta.Length()) 68 | { 69 | auto fuck(CenterOfEntityInWorld - ((delta * ForwardDot) + start)); 70 | v23 = fuck.Length(); 71 | } 72 | else 73 | { 74 | auto lol(CenterOfEntityInWorld - end); 75 | v23 = -lol.Length(); 76 | } 77 | } 78 | 79 | else 80 | v23 = -v20.Length(); 81 | 82 | if (v23 <= 60.f) 83 | { 84 | Ray_t ray; 85 | ray.Init(start, end); 86 | 87 | trace_t trace; 88 | g_trace->ClipRayToEntity(ray, 0x4600400B, ent, &trace); 89 | 90 | if (oldtrace->fraction > trace.fraction) 91 | *oldtrace = trace; 92 | } 93 | } 94 | 95 | bool entity::is_visible(C_CSPlayer* pEntity, int HitboxID) 96 | { 97 | auto pLocal = reinterpret_cast(g_entitylist->GetClientEntity(g_engine->GetLocalPlayer())); 98 | trace_t tr; 99 | Ray_t ray; 100 | 101 | CTraceFilter filter; 102 | filter.pSkip = pLocal; 103 | 104 | auto start = pLocal->get_eye_position(); 105 | auto end = get_hitbox_position(pEntity, HitboxID); 106 | ray.Init(start,end); 107 | g_trace->TraceRay(ray, 0x4600400B, &filter, &tr); 108 | 109 | // Check for player hitboxes extending outside their collision bounds 110 | //game::UTIL_ClipTraceToPlayers(start, end, 0x4600400B, &filter, &tr); 111 | 112 | //FixTraceRay(end, start, &tr, pEntity); 113 | 114 | return (tr.m_pEnt == pEntity || tr.fraction >= 0.98f); 115 | } 116 | 117 | bool entity::SetupBones(matrix3x4 *pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime) 118 | { 119 | return false; 120 | } -------------------------------------------------------------------------------- /src/tools/entity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../interfaces.h" 4 | #include "../sdk/CBaseEntity.h" 5 | 6 | namespace entity 7 | { 8 | Vector get_bone_position(C_CSPlayer * pEntity, int bone); 9 | Vector get_hitbox_position(C_CSPlayer * pEntity, int HitboxID); 10 | void fix_trace_ray(Vector end, Vector start, trace_t * oldtrace, C_BasePlayer * ent); 11 | bool is_visible(C_CSPlayer* pEntity, int HitboxID); 12 | bool SetupBones(matrix3x4 * pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime); 13 | } -------------------------------------------------------------------------------- /src/tools/fnv_hash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace detail 4 | { 5 | template 6 | struct size_dependant_data 7 | { 8 | using type = Type; 9 | constexpr static auto k_offset_basis = OffsetBasis; 10 | constexpr static auto k_prime = Prime; 11 | }; 12 | 13 | template 14 | struct size_selector; 15 | 16 | template <> 17 | struct size_selector<32> 18 | { 19 | using type = size_dependant_data; 20 | }; 21 | 22 | template <> 23 | struct size_selector<64> 24 | { 25 | using type = size_dependant_data; 26 | }; 27 | 28 | // Implements FNV-1a hash algorithm 29 | template 30 | class fnv_hash 31 | { 32 | private: 33 | using data_t = typename size_selector::type; 34 | 35 | public: 36 | using hash = typename data_t::type; 37 | 38 | private: 39 | constexpr static auto k_offset_basis = data_t::k_offset_basis; 40 | constexpr static auto k_prime = data_t::k_prime; 41 | 42 | public: 43 | template 44 | static __forceinline constexpr auto hash_constexpr(const char(&str)[N], const std::size_t size = N) -> hash 45 | { 46 | return static_cast(1ull * (size == 1 47 | ? (k_offset_basis ^ str[0]) 48 | : (hash_constexpr(str, size - 1) ^ str[size - 1])) * k_prime); 49 | } 50 | 51 | static auto __forceinline hash_runtime(const char* str) -> hash 52 | { 53 | auto result = k_offset_basis; 54 | do 55 | { 56 | result ^= *str++; 57 | result *= k_prime; 58 | } while (*(str - 1) != '\0'); 59 | 60 | return result; 61 | } 62 | }; 63 | } 64 | 65 | using fnv = ::detail::fnv_hash; 66 | 67 | #define FNV(str) (std::integral_constant::value) -------------------------------------------------------------------------------- /src/tools/game.cpp: -------------------------------------------------------------------------------- 1 | #include "game.h" 2 | #include "../SDK/sdk.h" 3 | #include "../interfaces.h" 4 | #include "../SDK/CBaseEntity.h" 5 | #include "../tools/math.h" 6 | 7 | auto game::RandomFloat(float min, float max) -> float 8 | { 9 | static auto oRandomFloat = reinterpret_cast(GetProcAddress(GetModuleHandleA("vstdlib.dll"), "RandomFloat")); 10 | return oRandomFloat(min, max); 11 | } 12 | 13 | auto game::RandomSeed(std::uint32_t seed) -> void 14 | { 15 | static auto oRandomSeed = reinterpret_cast(GetProcAddress(GetModuleHandleA("vstdlib.dll"), "RandomSeed")); 16 | oRandomSeed(seed); 17 | } 18 | 19 | void game::UTIL_ClipTraceToPlayers(const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask, ITraceFilter *filter, trace_t *tr) 20 | { 21 | static auto function = reinterpret_cast( 22 | tools::find_pattern("client.dll", "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 81 EC ? ? ? ? 8B 43 18")); 23 | function(vecAbsStart, vecAbsEnd, mask, filter, tr); 24 | } 25 | 26 | void game::UTIL_TraceLine(const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask, 27 | ITraceFilter *pFilter, trace_t *ptr) 28 | { 29 | Ray_t ray; 30 | ray.Init(vecAbsStart, vecAbsEnd); 31 | 32 | g_trace->TraceRay(ray, mask, pFilter, ptr); 33 | } 34 | 35 | void game::UTIL_TraceLine(const Vector& vecAbsStart, const Vector& vecAbsEnd, unsigned int mask, 36 | void *ignore, int collisionGroup, trace_t *ptr) 37 | { 38 | Ray_t ray; 39 | ray.Init(vecAbsStart, vecAbsEnd); 40 | CTraceFilter traceFilter; 41 | traceFilter.pSkip = ignore; 42 | 43 | g_trace->TraceRay(ray, mask, &traceFilter, ptr); 44 | } -------------------------------------------------------------------------------- /src/tools/game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "../SDK/IEngineTrace.h" 6 | 7 | namespace game 8 | { 9 | auto RandomFloat(float min, float max) -> float; 10 | auto RandomSeed(std::uint32_t seed) -> void; 11 | void UTIL_ClipTraceToPlayers(const Vector & vecAbsStart, const Vector & vecAbsEnd, unsigned int mask, ITraceFilter * filter, trace_t * tr); 12 | void UTIL_TraceLine(const Vector & vecAbsStart, const Vector & vecAbsEnd, unsigned int mask, ITraceFilter * pFilter, trace_t * ptr); 13 | void UTIL_TraceLine(const Vector & vecAbsStart, const Vector & vecAbsEnd, unsigned int mask, void * ignore, int collisionGroup, trace_t * ptr); 14 | } 15 | -------------------------------------------------------------------------------- /src/tools/math.cpp: -------------------------------------------------------------------------------- 1 | #include "math.h" 2 | 3 | void math::MatrixSetColumn(const Vector &in, int column, matrix3x4_t& out) 4 | { 5 | out[0][column] = in.x; 6 | out[1][column] = in.y; 7 | out[2][column] = in.z; 8 | } 9 | 10 | void math::SinCos(float a, float* s, float*c) 11 | { 12 | *s = sin(a); 13 | *c = cos(a); 14 | } 15 | 16 | void math::AngleVectors(const Vector &angles, Vector& forward) 17 | { 18 | Assert(forward); 19 | 20 | float sp, sy, cp, cy; 21 | 22 | SinCos(DEG2RAD(angles[YAW]), &sy, &cy); 23 | SinCos(DEG2RAD(angles[PITCH]), &sp, &cp); 24 | 25 | forward.x = cp * cy; 26 | forward.y = cp * sy; 27 | forward.z = -sp; 28 | } 29 | 30 | void math::AngleVectors(const Vector &angles, Vector *forward, Vector *right, Vector *up) 31 | { 32 | float sr, sp, sy, cr, cp, cy; 33 | 34 | SinCos(DEG2RAD(angles[YAW]), &sy, &cy); 35 | SinCos(DEG2RAD(angles[PITCH]), &sp, &cp); 36 | SinCos(DEG2RAD(angles[ROLL]), &sr, &cr); 37 | 38 | if (forward) 39 | { 40 | forward->x = cp * cy; 41 | forward->y = cp * sy; 42 | forward->z = -sp; 43 | } 44 | 45 | if (right) 46 | { 47 | right->x = (-1 * sr*sp*cy + -1 * cr*-sy); 48 | right->y = (-1 * sr*sp*sy + -1 * cr*cy); 49 | right->z = -1 * sr*cp; 50 | } 51 | 52 | if (up) 53 | { 54 | up->x = (cr*sp*cy + -sr * -sy); 55 | up->y = (cr*sp*sy + -sr * cy); 56 | up->z = cr * cp; 57 | } 58 | } 59 | 60 | __forceinline float math::DotProduct(const Vector& a, const Vector& b) 61 | { 62 | return (a.x * b.x + a.y * b.y + a.z * b.z); 63 | } 64 | 65 | __forceinline vec_t math::DotProduct(const vec_t *v1, const vec_t *v2) 66 | { 67 | return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; 68 | } 69 | 70 | void math::VectorTransform(const Vector in1, float in2[3][4], Vector &out) 71 | { 72 | out[0] = DotProduct(in1, Vector(in2[0][0], in2[0][1], in2[0][2])) + in2[0][3]; 73 | out[1] = DotProduct(in1, Vector(in2[1][0], in2[1][1], in2[1][2])) + in2[1][3]; 74 | out[2] = DotProduct(in1, Vector(in2[2][0], in2[2][1], in2[2][2])) + in2[2][3]; 75 | } 76 | 77 | void math::VectorTransform(const float *in1, const matrix3x4_t& in2, float *out) 78 | { 79 | out[0] = DotProduct(in1, in2[0]) + in2[0][3]; 80 | out[1] = DotProduct(in1, in2[1]) + in2[1][3]; 81 | out[2] = DotProduct(in1, in2[2]) + in2[2][3]; 82 | } 83 | 84 | void math::VectorTransform(const Vector in1, matrix3x4_t in2, Vector &out) 85 | { 86 | out[0] = DotProduct(in1, Vector(in2[0][0], in2[0][1], in2[0][2])) + in2[0][3]; 87 | out[1] = DotProduct(in1, Vector(in2[1][0], in2[1][1], in2[1][2])) + in2[1][3]; 88 | out[2] = DotProduct(in1, Vector(in2[2][0], in2[2][1], in2[2][2])) + in2[2][3]; 89 | } 90 | 91 | void math::VectorAngles(const Vector& forward, Vector &angles) 92 | { 93 | if (forward[1] == 0.0f && forward[0] == 0.0f) 94 | { 95 | angles[0] = (forward[2] > 0.0f) ? 270.0f : 90.0f; // Pitch (up/down) 96 | angles[1] = 0.0f; //yaw left/right 97 | } 98 | else 99 | { 100 | angles[0] = atan2(-forward[2], forward.Length2D()) * -180 / M_PI_F; 101 | angles[1] = atan2(forward[1], forward[0]) * 180 / M_PI_F; 102 | 103 | if (angles[1] > 90) 104 | angles[1] -= 180; 105 | else if (angles[1] < 90) 106 | angles[1] += 180; 107 | else if (angles[1] == 90) 108 | angles[1] = 0; 109 | } 110 | 111 | angles[2] = 0.0f; 112 | } 113 | 114 | void math::AngleMatrix(const QAngle &angles, matrix3x4_t& matrix) 115 | { 116 | float sr, sp, sy, cr, cp, cy; 117 | 118 | SinCos(DEG2RAD(angles[YAW]), &sy, &cy); 119 | SinCos(DEG2RAD(angles[PITCH]), &sp, &cp); 120 | SinCos(DEG2RAD(angles[ROLL]), &sr, &cr); 121 | 122 | // matrix = (YAW * PITCH) * ROLL 123 | matrix[0][0] = cp * cy; 124 | matrix[1][0] = cp * sy; 125 | matrix[2][0] = -sp; 126 | 127 | float crcy = cr * cy; 128 | float crsy = cr * sy; 129 | float srcy = sr * cy; 130 | float srsy = sr * sy; 131 | matrix[0][1] = sp * srcy - crsy; 132 | matrix[1][1] = sp * srsy + crcy; 133 | matrix[2][1] = sr * cp; 134 | 135 | matrix[0][2] = (sp*crcy + srsy); 136 | matrix[1][2] = (sp*crsy - srcy); 137 | matrix[2][2] = cr * cp; 138 | 139 | matrix[0][3] = 0.0f; 140 | matrix[1][3] = 0.0f; 141 | matrix[2][3] = 0.0f; 142 | } 143 | 144 | void math::AngleMatrix(const QAngle &angles, const Vector &position, matrix3x4_t& matrix) 145 | { 146 | AngleMatrix(angles, matrix); 147 | MatrixSetColumn(position, 3, matrix); 148 | } 149 | 150 | void math::correct_movement(Vector vOldAngles, CUserCmd* pCmd, float fOldForward, float fOldSidemove) 151 | { 152 | // side/forward move correction 153 | float deltaView; 154 | float f1; 155 | float f2; 156 | 157 | if (vOldAngles.y < 0.f) 158 | f1 = 360.0f + vOldAngles.y; 159 | else 160 | f1 = vOldAngles.y; 161 | 162 | if (pCmd->viewangles.y < 0.0f) 163 | f2 = 360.0f + pCmd->viewangles.y; 164 | else 165 | f2 = pCmd->viewangles.y; 166 | 167 | if (f2 < f1) 168 | deltaView = abs(f2 - f1); 169 | else 170 | deltaView = 360.0f - abs(f1 - f2); 171 | 172 | deltaView = 360.0f - deltaView; 173 | 174 | pCmd->forwardmove = cos(DEG2RAD(deltaView)) * fOldForward + cos(DEG2RAD(deltaView + 90.f)) * fOldSidemove; 175 | pCmd->sidemove = sin(DEG2RAD(deltaView)) * fOldForward + sin(DEG2RAD(deltaView + 90.f)) * fOldSidemove; 176 | } 177 | 178 | void math::clamp_angles(Vector& angle) 179 | { 180 | angle.x = std::clamp(angle.x, -89.f, 89.f); 181 | angle.y = std::remainderf(angle.y, 360.f); 182 | } -------------------------------------------------------------------------------- /src/tools/math.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../SDK/sdk.h" 4 | #include 5 | #include 6 | 7 | namespace math 8 | { 9 | void MatrixSetColumn(const Vector & in, int column, matrix3x4_t & out); 10 | void SinCos(float a, float* s, float* c); 11 | void AngleVectors(const Vector &angles, Vector &forward); 12 | void AngleVectors(const Vector & angles, Vector * forward, Vector * right, Vector * up); 13 | __forceinline float DotProduct(const Vector & a, const Vector & b); 14 | __forceinline vec_t DotProduct(const vec_t * v1, const vec_t * v2); 15 | void VectorTransform(const Vector in1, float in2[3][4], Vector & out); 16 | void VectorTransform(const float * in1, const matrix3x4_t & in2, float * out); 17 | void VectorTransform(const Vector in1, matrix3x4_t in2, Vector & out); 18 | void VectorAngles(const Vector &forward, Vector &angles); 19 | 20 | void AngleMatrix(const QAngle & angles, matrix3x4_t & matrix); 21 | 22 | void AngleMatrix(const QAngle & angles, const Vector & position, matrix3x4_t & matrix); 23 | 24 | void clamp_angles(Vector& angle); 25 | void correct_movement(Vector vOldAngles, CUserCmd* pCmd, float fOldForward, float fOldSidemove); 26 | } -------------------------------------------------------------------------------- /src/tools/netvar_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "netvar_manager.h" 2 | #include "../interfaces.h" 3 | #include 4 | 5 | #define DUMP_NETVARS 6 | 7 | #ifdef DUMP_NETVARS 8 | #define IF_DUMPING(...) __VA_ARGS__ 9 | #else 10 | #define IF_DUMPING(...) 11 | #endif 12 | 13 | IF_DUMPING(static FILE* s_fp;) 14 | 15 | netvar_manager::netvar_manager() 16 | { 17 | IF_DUMPING(fopen_s(&s_fp, "netvar_dump.txt", "w");) 18 | for (auto clazz = g_client->GetAllClasses(); clazz; clazz = clazz->m_pNext) 19 | if (clazz->m_pRecvTable) 20 | dump_recursive(clazz->m_pNetworkName, clazz->m_pRecvTable, 0); 21 | IF_DUMPING(fclose(s_fp);) 22 | } 23 | 24 | auto netvar_manager::dump_recursive(const char* base_class, RecvTable* table, const std::uint16_t offset) -> void 25 | { 26 | for (auto i = 0; i < table->m_nProps; ++i) 27 | { 28 | const auto prop_ptr = &table->m_pProps[i]; 29 | 30 | //Skip trash array items 31 | if (!prop_ptr || isdigit(prop_ptr->m_pVarName[0])) 32 | continue; 33 | 34 | //We dont care about the base class, we already know that 35 | if (strcmp(prop_ptr->m_pVarName, "baseclass") == 0) 36 | continue; 37 | 38 | if (prop_ptr->m_pDataTable != nullptr) 39 | dump_recursive(base_class, prop_ptr->m_pDataTable, std::uint16_t(offset + prop_ptr->m_Offset)); 40 | 41 | char hash_name[256]; 42 | 43 | strcpy_s(hash_name, base_class); 44 | strcat_s(hash_name, "->"); 45 | strcat_s(hash_name, prop_ptr->m_pVarName); 46 | 47 | const auto hash = fnv::hash_runtime(hash_name); 48 | const auto total_offset = std::uint16_t(offset + prop_ptr->m_Offset); 49 | 50 | IF_DUMPING(fprintf(s_fp, "%s\t0x%04X\t%s\n", base_class, total_offset, prop_ptr->m_pVarName);) 51 | 52 | m_props[hash] = 53 | { 54 | prop_ptr, 55 | total_offset 56 | }; 57 | } 58 | } -------------------------------------------------------------------------------- /src/tools/netvar_manager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../sdk/IBaseClientDll.h" 3 | #include "fnv_hash.h" 4 | #include 5 | #include 6 | 7 | class netvar_manager 8 | { 9 | private: 10 | struct stored_data 11 | { 12 | RecvProp* prop_ptr; 13 | std::uint16_t class_relative_offset; 14 | }; 15 | 16 | public: 17 | // Return a const instance, others shouldnt modify this. 18 | static auto get() -> const netvar_manager& 19 | { 20 | static netvar_manager instance; 21 | return instance; 22 | } 23 | 24 | auto get_offset(const fnv::hash hash) const -> std::uint16_t 25 | { 26 | return m_props.at(hash).class_relative_offset; 27 | } 28 | 29 | auto get_prop(const fnv::hash hash) const -> RecvProp* 30 | { 31 | return m_props.at(hash).prop_ptr; 32 | } 33 | 34 | // Prevent instruction cache pollution caused by automatic 35 | // inlining of `get` and get_offset every netvar usage when 36 | // there are a lot of netvars 37 | __declspec(noinline) static auto get_offset_by_hash(const fnv::hash hash) -> std::uint16_t 38 | { 39 | return get().get_offset(hash); 40 | } 41 | 42 | template 43 | static auto to_address(void* ptr) -> std::uintptr_t 44 | { 45 | static auto offset = std::uint16_t(0); 46 | if (!offset) 47 | offset = get_offset_by_hash(Hash); 48 | return std::uintptr_t(ptr) + offset; 49 | } 50 | 51 | private: 52 | netvar_manager(); 53 | auto dump_recursive(const char* base_class, RecvTable* table, std::uint16_t offset) -> void; 54 | 55 | private: 56 | std::map m_props; 57 | }; 58 | 59 | 60 | #define PNETVAR_OFFSET(funcname, class_name, var_name, offset, ...) \ 61 | auto funcname() -> std::add_pointer_t<__VA_ARGS__> \ 62 | { \ 63 | constexpr auto hash = fnv::hash_constexpr(class_name "->" var_name); \ 64 | const auto addr = netvar_manager::to_address(this); \ 65 | return reinterpret_cast>(addr); \ 66 | } 67 | 68 | #define PNETVAR(funcname, class_name, var_name, ...) \ 69 | PNETVAR_OFFSET(funcname, class_name, var_name, 0, __VA_ARGS__) 70 | 71 | #define NETVAR_OFFSET(funcname, class_name, var_name, offset, ...) \ 72 | auto funcname() -> std::add_lvalue_reference_t<__VA_ARGS__> \ 73 | { \ 74 | constexpr auto hash = fnv::hash_constexpr(class_name "->" var_name); \ 75 | const auto addr = netvar_manager::to_address(this); \ 76 | return *reinterpret_cast>(addr); \ 77 | } 78 | 79 | #define NETVAR(funcname, class_name, var_name, ...) \ 80 | NETVAR_OFFSET(funcname, class_name, var_name, 0, __VA_ARGS__) 81 | 82 | #define NETPROP(funcname, class_name, var_name) \ 83 | static auto funcname() -> RecvProp* \ 84 | { \ 85 | constexpr auto hash = fnv::hash_constexpr(class_name "->" var_name); \ 86 | static auto prop_ptr = netvar_manager::get().get_prop(hash); \ 87 | return prop_ptr; \ 88 | } -------------------------------------------------------------------------------- /src/tools/tools.cpp: -------------------------------------------------------------------------------- 1 | #include "tools.h" 2 | 3 | uintptr_t tools::find_pattern(const char* szModule, const char* szSignature) 4 | { 5 | MODULEINFO modInfo; 6 | GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(szModule), &modInfo, sizeof(MODULEINFO)); 7 | uintptr_t startAddress = reinterpret_cast(modInfo.lpBaseOfDll); 8 | uintptr_t endAddress = startAddress + modInfo.SizeOfImage; 9 | const char* pat = szSignature; 10 | uintptr_t firstMatch = 0; 11 | for (uintptr_t pCur = startAddress; pCur < endAddress; pCur++) 12 | { 13 | if (!*pat) return firstMatch; 14 | if (*(PBYTE)pat == '\?' || *(BYTE*)pCur == getByte(pat)) 15 | { 16 | if (!firstMatch) firstMatch = pCur; 17 | if (!pat[2]) return firstMatch; 18 | if (*(PWORD)pat == '\?\?' || *(PBYTE)pat != '\?') pat += 3; 19 | else pat += 2; 20 | } 21 | else 22 | { 23 | pat = szSignature; 24 | firstMatch = 0; 25 | } 26 | } 27 | 28 | return NULL; 29 | } 30 | 31 | std::uintptr_t tools::get_rel32(std::uintptr_t address, std::uintptr_t offset, std::uintptr_t instruction_size) 32 | { 33 | return address + *reinterpret_cast(address + offset) + instruction_size; 34 | } 35 | 36 | bool tools::IsCodePtr(void* ptr) 37 | { 38 | constexpr const DWORD protect_flags = PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY; 39 | 40 | MEMORY_BASIC_INFORMATION out; 41 | VirtualQuery(ptr, &out, sizeof out); 42 | 43 | return out.Type 44 | && !(out.Protect & (PAGE_GUARD | PAGE_NOACCESS)) 45 | && out.Protect & protect_flags; 46 | } -------------------------------------------------------------------------------- /src/tools/tools.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace tools 10 | { 11 | #define INRANGE(x,a,b) (x >= a && x <= b) 12 | #define getBits( x ) (INRANGE((x&(~0x20)),'A','F') ? ((x&(~0x20)) - 'A' + 0xa) : (INRANGE(x,'0','9') ? x - '0' : 0)) 13 | #define getByte( x ) (getBits(x[0]) << 4 | getBits(x[1])) 14 | 15 | uintptr_t find_pattern(const char* szModule, const char* szSignature); 16 | std::uintptr_t get_rel32(std::uintptr_t address, std::uintptr_t offset, std::uintptr_t instruction_size); 17 | bool IsCodePtr(void * ptr); 18 | } -------------------------------------------------------------------------------- /src/tools/virtuals.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | Fn get_vfunc(void* class_base, size_t index) 5 | { 6 | return (*reinterpret_cast(class_base))[index]; 7 | } -------------------------------------------------------------------------------- /src/tools/vmt_hook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "tools.h" 7 | 8 | class cvmt_hook 9 | { 10 | public: 11 | cvmt_hook(void* classptr) 12 | { 13 | this->m_class_pointer = reinterpret_cast(classptr); 14 | m_old_vmt = *m_class_pointer; 15 | 16 | size_t table_size = 0; 17 | while (m_old_vmt[table_size] && tools::IsCodePtr(m_old_vmt[table_size])) 18 | table_size++; 19 | 20 | m_new_vmt = new void*[table_size + 1]; 21 | memcpy(&m_new_vmt[1], m_old_vmt, sizeof(void*) * table_size); 22 | m_new_vmt[0] = m_old_vmt[-1]; 23 | 24 | *m_class_pointer = &m_new_vmt[1]; 25 | } 26 | 27 | ~cvmt_hook() 28 | { 29 | *m_class_pointer = m_old_vmt; 30 | delete[] m_new_vmt; 31 | } 32 | 33 | template 34 | fn hook(size_t index, void* new_function) 35 | { 36 | if (new_function) 37 | m_new_vmt[index + 1] = new_function; 38 | return reinterpret_cast(m_old_vmt[index]); 39 | } 40 | 41 | private: 42 | void*** m_class_pointer = nullptr; 43 | void** m_old_vmt = nullptr; 44 | void** m_new_vmt = nullptr; 45 | }; --------------------------------------------------------------------------------