├── .gitignore ├── AnvilAusar ├── AnvilAusar.vcxproj ├── AnvilAusar.vcxproj.filters └── Source │ ├── EngineImpl.cpp │ ├── EngineImpl.hpp │ ├── Globals.cpp │ └── Hooks │ ├── Windows.cpp │ └── Windows.hpp ├── AnvilClient.sln ├── AnvilClient ├── AnvilClient.vcxproj ├── AnvilClient.vcxproj.filters ├── PreBuild.bat └── Source │ ├── Client │ ├── ClientImpl.cpp │ └── ClientImpl.hpp │ └── Source.cpp ├── AnvilCommon ├── AnvilCommon.vcxproj ├── AnvilCommon.vcxproj.filters ├── Depends │ ├── Include │ │ └── MinHook.h │ └── Library │ │ ├── x64 │ │ ├── Debug │ │ │ └── libMinHook.lib │ │ └── Release │ │ │ └── libMinHook.lib │ │ └── x86 │ │ ├── Debug │ │ └── libMinHook.lib │ │ └── Release │ │ └── libMinHook.lib └── Source │ ├── BuildInfo.hpp │ ├── Globals.hpp │ ├── Interfaces │ ├── Client.hpp │ ├── Engine.hpp │ └── Initializable.hpp │ └── Utils │ ├── Hook.cpp │ ├── Hook.hpp │ ├── Logger.cpp │ ├── Logger.hpp │ ├── Patch.cpp │ ├── Patch.hpp │ ├── Util.cpp │ └── Util.hpp ├── AnvilEldorado ├── AnvilEldorado.vcxproj ├── AnvilEldorado.vcxproj.filters ├── Depends │ ├── Include │ │ └── MinHook.h │ └── Library │ │ ├── libMinHook-x86-v140-mt.lib │ │ └── libMinHook-x86-v140-mtd.lib └── Source │ ├── Blam │ ├── Cache │ │ └── StringIDCacheHeader.hpp │ ├── Data │ │ ├── BitStream.cpp │ │ ├── BitStream.hpp │ │ ├── DataArray.cpp │ │ ├── DataArray.hpp │ │ ├── DataPoolBase.cpp │ │ ├── DataPoolBase.hpp │ │ ├── DatumBase.cpp │ │ ├── DatumBase.hpp │ │ ├── DatumIndex.cpp │ │ ├── DatumIndex.hpp │ │ ├── LruvCacheBase.cpp │ │ └── LruvCacheBase.hpp │ ├── Game │ │ ├── Damage.hpp │ │ ├── Events.hpp │ │ ├── Medals.hpp │ │ ├── Players │ │ │ ├── ClientPlayerProperties.hpp │ │ │ ├── PlayerArmor.hpp │ │ │ ├── PlayerColor.hpp │ │ │ ├── PlayerCustomization.hpp │ │ │ ├── PlayerDatum.hpp │ │ │ └── PlayerProperties.hpp │ │ ├── Stats.cpp │ │ ├── Stats.hpp │ │ ├── Stats │ │ │ ├── PlayerKilledPlayerStats.hpp │ │ │ ├── PlayerStats.hpp │ │ │ ├── PlayerVsStats.hpp │ │ │ └── WeaponStats.hpp │ │ └── Variants.hpp │ ├── Input │ │ ├── ActionState.hpp │ │ ├── ActionStateFlags.hpp │ │ ├── BindingsPreferences.hpp │ │ ├── BindingsTable.hpp │ │ ├── ConfigurableAction.hpp │ │ ├── ControllerButton.hpp │ │ ├── GameAction.hpp │ │ ├── InputType.hpp │ │ ├── KeyCode.hpp │ │ ├── KeyEvent.hpp │ │ ├── KeyEventModifiers.hpp │ │ ├── KeyEventType.hpp │ │ ├── MouseButton.hpp │ │ └── UIButtonCode.hpp │ ├── Math │ │ ├── Angle.cpp │ │ ├── Angle.hpp │ │ ├── BasePoint2D.hpp │ │ ├── Bounds.hpp │ │ ├── ColorARGB.cpp │ │ ├── ColorARGB.hpp │ │ ├── ColorRGB.cpp │ │ ├── ColorRGB.hpp │ │ ├── Point2D.cpp │ │ ├── Point2D.hpp │ │ ├── RealColorARGB.cpp │ │ ├── RealColorARGB.hpp │ │ ├── RealColorRGB.cpp │ │ ├── RealColorRGB.hpp │ │ ├── RealEulerAngles2D.cpp │ │ ├── RealEulerAngles2D.hpp │ │ ├── RealEulerAngles3D.cpp │ │ ├── RealEulerAngles3D.hpp │ │ ├── RealMatrix3x3.cpp │ │ ├── RealMatrix3x3.hpp │ │ ├── RealMatrix4x3.cpp │ │ ├── RealMatrix4x3.hpp │ │ ├── RealOrientation3D.cpp │ │ ├── RealOrientation3D.hpp │ │ ├── RealPlane2D.cpp │ │ ├── RealPlane2D.hpp │ │ ├── RealPlane3D.cpp │ │ ├── RealPlane3D.hpp │ │ ├── RealPoint2D.cpp │ │ ├── RealPoint2D.hpp │ │ ├── RealPoint3D.cpp │ │ ├── RealPoint3D.hpp │ │ ├── RealQuaternion.cpp │ │ ├── RealQuaternion.hpp │ │ ├── RealRectangle2D.cpp │ │ ├── RealRectangle2D.hpp │ │ ├── RealRectangle3D.cpp │ │ ├── RealRectangle3D.hpp │ │ ├── RealVector2D.cpp │ │ ├── RealVector2D.hpp │ │ ├── RealVector3D.cpp │ │ ├── RealVector3D.hpp │ │ ├── Rectangle2D.cpp │ │ └── Rectangle2D.hpp │ ├── Memory │ │ ├── GlobalMemoryMap.cpp │ │ └── GlobalMemoryMap.hpp │ ├── Network │ │ ├── Session.cpp │ │ └── Session.hpp │ ├── Objects │ │ ├── ObjectData.hpp │ │ └── ObjectType.hpp │ ├── Sounds │ │ └── Noise.hpp │ ├── Tags │ │ ├── Game │ │ │ ├── CacheFileGlobalTags.hpp │ │ │ ├── Globals.hpp │ │ │ ├── MultiplayerGlobals.hpp │ │ │ └── VFilesList.hpp │ │ ├── Items │ │ │ ├── Item.hpp │ │ │ └── Weapon.hpp │ │ ├── Objects │ │ │ └── Object.hpp │ │ ├── Scenario │ │ │ └── Scenario.hpp │ │ ├── Tag.cpp │ │ ├── Tag.hpp │ │ ├── TagBlock.hpp │ │ ├── TagData.hpp │ │ ├── TagInstance.hpp │ │ ├── TagReference.hpp │ │ └── UserInterface │ │ │ ├── ChudDefinition.hpp │ │ │ └── ChudGlobalsDefinition.hpp │ └── Text │ │ ├── StringID.cpp │ │ └── StringID.hpp │ ├── Camera.cpp │ ├── Camera.hpp │ ├── Engine.cpp │ ├── Engine.hpp │ ├── EngineImpl.cpp │ ├── EngineImpl.hpp │ ├── Forge.cpp │ ├── Forge.hpp │ ├── Game │ ├── Audio │ │ ├── AudioImpl.cpp │ │ ├── AudioImpl.hpp │ │ ├── Hooks.cpp │ │ └── Hooks.hpp │ ├── Cache │ │ ├── StringIdCache.cpp │ │ └── StringIdCache.hpp │ ├── Input │ │ ├── InputImpl.cpp │ │ └── InputImpl.hpp │ ├── Networking │ │ ├── Hooks.cpp │ │ ├── Hooks.hpp │ │ ├── NetworkingImpl.cpp │ │ ├── NetworkingImpl.hpp │ │ ├── XnAddr.hpp │ │ ├── XnKey.hpp │ │ └── XnKid.hpp │ ├── Players │ │ ├── Hooks.cpp │ │ ├── Hooks.hpp │ │ ├── PlayerArmorExtension.cpp │ │ ├── PlayerArmorExtension.hpp │ │ ├── PlayerImpl.cpp │ │ ├── PlayerImpl.hpp │ │ ├── PlayerPropertiesExtender.cpp │ │ ├── PlayerPropertiesExtender.hpp │ │ ├── PlayerPropertiesExtension.hpp │ │ └── PlayerPropertiesExtensionBase.hpp │ └── UI │ │ ├── Hooks.cpp │ │ ├── Hooks.hpp │ │ ├── UIImpl.cpp │ │ └── UIImpl.hpp │ ├── GameImpl.cpp │ ├── GameImpl.hpp │ ├── Globals.cpp │ ├── Graphics.cpp │ ├── Graphics.hpp │ ├── Hooking │ └── Hooking.hpp │ ├── Input.cpp │ ├── Input.hpp │ ├── Network.cpp │ ├── Network.hpp │ ├── Player.cpp │ ├── Player.hpp │ ├── UserInterface.cpp │ └── UserInterface.hpp ├── LICENSE └── README.md /.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 Studo 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 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | *.db 77 | *.opendb 78 | 79 | # Visual Studio profiler 80 | *.psess 81 | *.vsp 82 | *.vspx 83 | 84 | # TFS 2012 Local Workspace 85 | $tf/ 86 | 87 | # Guidance Automation Toolkit 88 | *.gpState 89 | 90 | # ReSharper is a .NET coding add-in 91 | _ReSharper*/ 92 | *.[Rr]e[Ss]harper 93 | *.DotSettings.user 94 | 95 | # JustCode is a .NET coding addin-in 96 | .JustCode 97 | 98 | # TeamCity is a build add-in 99 | _TeamCity* 100 | 101 | # DotCover is a Code Coverage Tool 102 | *.dotCover 103 | 104 | # NCrunch 105 | _NCrunch_* 106 | .*crunch*.local.xml 107 | 108 | # MightyMoose 109 | *.mm.* 110 | AutoTest.Net/ 111 | 112 | # Web workbench (sass) 113 | .sass-cache/ 114 | 115 | # Installshield output folder 116 | [Ee]xpress/ 117 | 118 | # DocProject is a documentation generator add-in 119 | DocProject/buildhelp/ 120 | DocProject/Help/*.HxT 121 | DocProject/Help/*.HxC 122 | DocProject/Help/*.hhc 123 | DocProject/Help/*.hhk 124 | DocProject/Help/*.hhp 125 | DocProject/Help/Html2 126 | DocProject/Help/html 127 | 128 | # Click-Once directory 129 | publish/ 130 | 131 | # Publish Web Output 132 | *.[Pp]ublish.xml 133 | *.azurePubxml 134 | # TODO: Comment the next line if you want to checkin your web deploy settings 135 | # but database connection strings (with potential passwords) will be unencrypted 136 | *.pubxml 137 | *.publishproj 138 | 139 | # NuGet Packages 140 | *.nupkg 141 | # The packages folder can be ignored because of Package Restore 142 | **/packages/* 143 | # except build/, which is used as an MSBuild target. 144 | !**/packages/build/ 145 | # Uncomment if necessary however generally it will be regenerated when needed 146 | #!**/packages/repositories.config 147 | 148 | # Windows Azure Build Output 149 | csx/ 150 | *.build.csdef 151 | 152 | # Windows Store app package directory 153 | AppPackages/ 154 | 155 | # Others 156 | *.[Cc]ache 157 | ClientBin/ 158 | [Ss]tyle[Cc]op.* 159 | ~$* 160 | *~ 161 | *.dbmdl 162 | *.dbproj.schemaview 163 | *.pfx 164 | *.publishsettings 165 | node_modules/ 166 | bower_components/ 167 | 168 | # RIA/Silverlight projects 169 | Generated_Code/ 170 | 171 | # Backup & report files from converting an old project file 172 | # to a newer Visual Studio version. Backup files are not needed, 173 | # because we have git ;-) 174 | _UpgradeReport_Files/ 175 | Backup*/ 176 | UpgradeLog*.XML 177 | UpgradeLog*.htm 178 | 179 | # SQL Server files 180 | *.mdf 181 | *.ldf 182 | 183 | # Business Intelligence projects 184 | *.rdl.data 185 | *.bim.layout 186 | *.bim_*.settings 187 | 188 | # Microsoft Fakes 189 | FakesAssemblies/ 190 | 191 | # Node.js Tools for Visual Studio 192 | .ntvs_analysis.dat 193 | 194 | # Visual Studio 6 build log 195 | *.plg 196 | 197 | # Visual Studio 6 workspace options file 198 | *.opt 199 | 200 | # Except our library directory 201 | !/AnvilCommon/Depends/Library/** 202 | -------------------------------------------------------------------------------- /AnvilAusar/AnvilAusar.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /AnvilAusar/Source/EngineImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "EngineImpl.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | using namespace AnvilAusar; 9 | 10 | bool EngineImpl::Init() 11 | { 12 | if (!InitializeDirectories()) 13 | return false; 14 | 15 | return true; 16 | } 17 | 18 | bool EngineImpl::InitializeDirectories() 19 | { 20 | PWSTR s_LocalAppDataPath = nullptr; 21 | 22 | if (SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &s_LocalAppDataPath) != S_OK) 23 | { 24 | WriteLog("There was an error retrieving the local app data path."); 25 | return false; 26 | } 27 | 28 | std::wstring s_Path(s_LocalAppDataPath); 29 | 30 | m_LocalAppDataPath = std::string(s_Path.begin(), s_Path.end()); 31 | m_LocalCachePath = m_LocalAppDataPath.substr(0, m_LocalAppDataPath.length() - 3) + "\\LocalCache"; 32 | 33 | WriteLog("Local Application Data Path: %s.", m_LocalAppDataPath.c_str()); 34 | 35 | return true; 36 | } 37 | 38 | uint8_t* EngineImpl::ExecutableBase() 39 | { 40 | return nullptr; 41 | } 42 | 43 | size_t EngineImpl::ExecutableSize() 44 | { 45 | return 0; 46 | } 47 | 48 | std::shared_ptr EngineImpl::GetStringCache() 49 | { 50 | return nullptr; 51 | } -------------------------------------------------------------------------------- /AnvilAusar/Source/EngineImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace AnvilAusar 6 | { 7 | class EngineImpl : 8 | public AnvilCommon::Engine 9 | { 10 | private: 11 | std::string m_LocalAppDataPath; 12 | std::string m_LocalCachePath; 13 | 14 | protected: 15 | bool InitializeDirectories(); 16 | 17 | public: 18 | virtual bool Init(); 19 | 20 | virtual uint8_t* ExecutableBase(); 21 | virtual size_t ExecutableSize(); 22 | virtual std::shared_ptr GetStringCache(); 23 | }; 24 | } -------------------------------------------------------------------------------- /AnvilAusar/Source/Globals.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | std::string AnvilCommon::g_BuildInfo = "AnvilAusar Client - " + std::string(__DATE__) + " - Build: " + std::to_string(ANVIL_BUILD); 5 | 6 | void* AnvilCommon::Internal_GetThreadStorage(const size_t p_Offset) 7 | { 8 | // TODO: Implement 9 | return nullptr; 10 | } -------------------------------------------------------------------------------- /AnvilAusar/Source/Hooks/Windows.cpp: -------------------------------------------------------------------------------- 1 | #include "Windows.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace AnvilAusar::Hooks; 7 | 8 | bool WindowsHooks::Init() 9 | { 10 | auto s_KernelBaseHandle = GetModuleHandle("KernelBase.dll"); 11 | if (!s_KernelBaseHandle) 12 | { 13 | WriteLog("Could not get the handle of kernelbase."); 14 | return false; 15 | } 16 | 17 | auto s_CreateFileW = GetProcAddress(s_KernelBaseHandle, "CreateFileW"); 18 | 19 | return false; 20 | } 21 | 22 | /* 23 | ============================================================================== 24 | Hooked Functions 25 | ============================================================================== 26 | */ 27 | 28 | void* WindowsHooks::c_CreateFileW(const wchar_t * p_FileName, uint32_t p_Access, void * p_SecurityAttributes, uint32_t p_Creation, uint32_t p_Attributes, void * p_Template) 29 | { 30 | auto s_Ret = o_CreateFileW(p_FileName, p_Access, p_SecurityAttributes, p_Creation, p_Attributes, p_Template); 31 | 32 | WriteLog("[File Access] %S %x.", p_FileName, s_Ret); 33 | 34 | return s_Ret; 35 | } -------------------------------------------------------------------------------- /AnvilAusar/Source/Hooks/Windows.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace AnvilAusar::Hooks 6 | { 7 | class WindowsHooks : 8 | public AnvilCommon::Initializable 9 | { 10 | private: 11 | typedef void* (*CreateFileW_t)(const wchar_t* p_FileName, uint32_t p_Access, void* p_SecurityAttributes, uint32_t p_Creation, uint32_t p_Attributes, void* p_Template); 12 | static CreateFileW_t o_CreateFileW; 13 | static void* c_CreateFileW(const wchar_t* p_FileName, uint32_t p_Access, void* p_SecurityAttributes, uint32_t p_Creation, uint32_t p_Attributes, void* p_Template); 14 | 15 | public: 16 | virtual bool Init(); 17 | }; 18 | } -------------------------------------------------------------------------------- /AnvilClient.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.9 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnvilClient", "AnvilClient\AnvilClient.vcxproj", "{15EC28EA-8932-40C4-94A9-2C6CA9957F22}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {F7267A5F-7009-40A3-B523-424279DEF2C7} = {F7267A5F-7009-40A3-B523-424279DEF2C7} 9 | {349E5495-8A3F-4057-B86B-E192663DA85E} = {349E5495-8A3F-4057-B86B-E192663DA85E} 10 | {89774CFE-D1EA-435F-B484-DC092221BE23} = {89774CFE-D1EA-435F-B484-DC092221BE23} 11 | EndProjectSection 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnvilCommon", "AnvilCommon\AnvilCommon.vcxproj", "{89774CFE-D1EA-435F-B484-DC092221BE23}" 14 | EndProject 15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnvilEldorado", "AnvilEldorado\AnvilEldorado.vcxproj", "{F7267A5F-7009-40A3-B523-424279DEF2C7}" 16 | ProjectSection(ProjectDependencies) = postProject 17 | {89774CFE-D1EA-435F-B484-DC092221BE23} = {89774CFE-D1EA-435F-B484-DC092221BE23} 18 | EndProjectSection 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnvilAusar", "AnvilAusar\AnvilAusar.vcxproj", "{349E5495-8A3F-4057-B86B-E192663DA85E}" 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|Ausar = Debug|Ausar 25 | Debug|Eldorado = Debug|Eldorado 26 | Release|Ausar = Release|Ausar 27 | Release|Eldorado = Release|Eldorado 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {15EC28EA-8932-40C4-94A9-2C6CA9957F22}.Debug|Ausar.ActiveCfg = Debug|x64 31 | {15EC28EA-8932-40C4-94A9-2C6CA9957F22}.Debug|Ausar.Build.0 = Debug|x64 32 | {15EC28EA-8932-40C4-94A9-2C6CA9957F22}.Debug|Eldorado.ActiveCfg = Debug|Win32 33 | {15EC28EA-8932-40C4-94A9-2C6CA9957F22}.Debug|Eldorado.Build.0 = Debug|Win32 34 | {15EC28EA-8932-40C4-94A9-2C6CA9957F22}.Release|Ausar.ActiveCfg = Release|x64 35 | {15EC28EA-8932-40C4-94A9-2C6CA9957F22}.Release|Ausar.Build.0 = Release|x64 36 | {15EC28EA-8932-40C4-94A9-2C6CA9957F22}.Release|Eldorado.ActiveCfg = Release|Win32 37 | {15EC28EA-8932-40C4-94A9-2C6CA9957F22}.Release|Eldorado.Build.0 = Release|Win32 38 | {89774CFE-D1EA-435F-B484-DC092221BE23}.Debug|Ausar.ActiveCfg = Debug|x64 39 | {89774CFE-D1EA-435F-B484-DC092221BE23}.Debug|Ausar.Build.0 = Debug|x64 40 | {89774CFE-D1EA-435F-B484-DC092221BE23}.Debug|Eldorado.ActiveCfg = Debug|Win32 41 | {89774CFE-D1EA-435F-B484-DC092221BE23}.Debug|Eldorado.Build.0 = Debug|Win32 42 | {89774CFE-D1EA-435F-B484-DC092221BE23}.Release|Ausar.ActiveCfg = Release|x64 43 | {89774CFE-D1EA-435F-B484-DC092221BE23}.Release|Ausar.Build.0 = Release|x64 44 | {89774CFE-D1EA-435F-B484-DC092221BE23}.Release|Eldorado.ActiveCfg = Release|Win32 45 | {89774CFE-D1EA-435F-B484-DC092221BE23}.Release|Eldorado.Build.0 = Release|Win32 46 | {F7267A5F-7009-40A3-B523-424279DEF2C7}.Debug|Ausar.ActiveCfg = Debug|x64 47 | {F7267A5F-7009-40A3-B523-424279DEF2C7}.Debug|Eldorado.ActiveCfg = Debug|Win32 48 | {F7267A5F-7009-40A3-B523-424279DEF2C7}.Debug|Eldorado.Build.0 = Debug|Win32 49 | {F7267A5F-7009-40A3-B523-424279DEF2C7}.Release|Ausar.ActiveCfg = Release|x64 50 | {F7267A5F-7009-40A3-B523-424279DEF2C7}.Release|Eldorado.ActiveCfg = Release|Win32 51 | {F7267A5F-7009-40A3-B523-424279DEF2C7}.Release|Eldorado.Build.0 = Release|Win32 52 | {349E5495-8A3F-4057-B86B-E192663DA85E}.Debug|Ausar.ActiveCfg = Debug|x64 53 | {349E5495-8A3F-4057-B86B-E192663DA85E}.Debug|Ausar.Build.0 = Debug|x64 54 | {349E5495-8A3F-4057-B86B-E192663DA85E}.Debug|Eldorado.ActiveCfg = Debug|Win32 55 | {349E5495-8A3F-4057-B86B-E192663DA85E}.Release|Ausar.ActiveCfg = Release|x64 56 | {349E5495-8A3F-4057-B86B-E192663DA85E}.Release|Ausar.Build.0 = Release|x64 57 | {349E5495-8A3F-4057-B86B-E192663DA85E}.Release|Eldorado.ActiveCfg = Release|Win32 58 | EndGlobalSection 59 | GlobalSection(SolutionProperties) = preSolution 60 | HideSolutionNode = FALSE 61 | EndGlobalSection 62 | EndGlobal 63 | -------------------------------------------------------------------------------- /AnvilClient/AnvilClient.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /AnvilClient/PreBuild.bat: -------------------------------------------------------------------------------- 1 | FOR /f "usebackq tokens=1,2,3 delims= " %%a IN ("..\AnvilCommon\Source\BuildInfo.hpp") DO ( 2 | set /a buildnum = %%c 3 | set /a newbuild = %%c + 1 4 | ) 5 | 6 | @echo. > "..\AnvilCommon\Source\BuildInfo.hpp" 7 | @echo #define ANVIL_BUILD %newbuild% > "..\AnvilCommon\Source\BuildInfo.hpp" -------------------------------------------------------------------------------- /AnvilClient/Source/Client/ClientImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "ClientImpl.hpp" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | using namespace AnvilCommon; 12 | using namespace Anvil::Client; 13 | 14 | #ifdef ANVIL_DEW 15 | #pragma comment(lib, "AnvilEldorado") 16 | #endif 17 | 18 | #ifdef ANVIL_AUSAR 19 | #pragma comment(lib, "AnvilAusar") 20 | #endif 21 | 22 | extern std::shared_ptr GetClientInterface() 23 | { 24 | return ClientImpl::GetInstance(); 25 | } 26 | 27 | std::shared_ptr ClientImpl::GetInstance() 28 | { 29 | static auto s_Instance = std::make_shared(); 30 | return s_Instance; 31 | } 32 | 33 | bool ClientImpl::Init() 34 | { 35 | // Initialize MinHook 36 | if (MH_Initialize() != MH_OK) 37 | { 38 | WriteLog("Failed to initialize libMinHook."); 39 | return false; 40 | } 41 | 42 | #ifdef ANVIL_DEW 43 | // Initialize Eldorado 44 | m_Engine = std::shared_ptr(new AnvilEldorado::EngineImpl); 45 | #endif 46 | 47 | #ifdef ANVIL_AUSAR 48 | // Initialize Ausar 49 | m_Engine = std::shared_ptr(new AnvilAusar::EngineImpl); 50 | #endif 51 | 52 | if (!m_Engine->Init()) 53 | { 54 | WriteLog("Failed to initialize engine."); 55 | return false; 56 | } 57 | 58 | #if defined(_DEBUG) && defined(ANVIL_DEW) 59 | WriteLog("Sleeping for 5s."); 60 | Sleep(15000); 61 | #endif 62 | 63 | Utils::Util::ResumeAllThreads(); 64 | 65 | return true; 66 | } 67 | 68 | std::shared_ptr ClientImpl::GetEngine() 69 | { 70 | return m_Engine; 71 | } -------------------------------------------------------------------------------- /AnvilClient/Source/Client/ClientImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace Anvil::Client 6 | { 7 | class ClientImpl : 8 | public AnvilCommon::Client 9 | { 10 | private: 11 | std::shared_ptr m_Engine; 12 | 13 | public: 14 | static std::shared_ptr GetInstance(); 15 | 16 | virtual bool Init(); 17 | virtual std::shared_ptr GetEngine(); 18 | }; 19 | } -------------------------------------------------------------------------------- /AnvilClient/Source/Source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | DWORD WINAPI Initialize(LPVOID) 7 | { 8 | // Initialize the logger before anything else 9 | AnvilCommon::Utils::Logger::GetInstance()->Init(); 10 | 11 | // Initialize the client, which will in turn initialize Eldorado or Ausar engine's 12 | Anvil::Client::ClientImpl::GetInstance()->Init(); 13 | 14 | return 0; 15 | } 16 | 17 | BOOL WINAPI DllMain(HINSTANCE p_Instance, DWORD p_Reason, LPVOID p_Reserved) 18 | { 19 | if (p_Reason == DLL_PROCESS_ATTACH) 20 | CreateThread(nullptr, 0, Initialize, nullptr, 0, nullptr); 21 | 22 | return TRUE; 23 | } -------------------------------------------------------------------------------- /AnvilCommon/AnvilCommon.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /AnvilCommon/Depends/Library/x64/Debug/libMinHook.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnvilOnline/AnvilClient/9b7751d9583d7221fd9c9f1b864f27e7ff9fcf79/AnvilCommon/Depends/Library/x64/Debug/libMinHook.lib -------------------------------------------------------------------------------- /AnvilCommon/Depends/Library/x64/Release/libMinHook.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnvilOnline/AnvilClient/9b7751d9583d7221fd9c9f1b864f27e7ff9fcf79/AnvilCommon/Depends/Library/x64/Release/libMinHook.lib -------------------------------------------------------------------------------- /AnvilCommon/Depends/Library/x86/Debug/libMinHook.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnvilOnline/AnvilClient/9b7751d9583d7221fd9c9f1b864f27e7ff9fcf79/AnvilCommon/Depends/Library/x86/Debug/libMinHook.lib -------------------------------------------------------------------------------- /AnvilCommon/Depends/Library/x86/Release/libMinHook.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnvilOnline/AnvilClient/9b7751d9583d7221fd9c9f1b864f27e7ff9fcf79/AnvilCommon/Depends/Library/x86/Release/libMinHook.lib -------------------------------------------------------------------------------- /AnvilCommon/Source/BuildInfo.hpp: -------------------------------------------------------------------------------- 1 | #define ANVIL_BUILD 588 2 | -------------------------------------------------------------------------------- /AnvilCommon/Source/Globals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace AnvilCommon 5 | { 6 | extern std::string g_BuildInfo; 7 | 8 | extern void *Internal_GetThreadStorage(const size_t p_Offset = 0); 9 | extern void *Internal_GetModuleStorage(const size_t p_Offset = 0); 10 | 11 | template 12 | T *GetThreadStorage(const size_t p_Offset = 0) 13 | { 14 | return *reinterpret_cast(Internal_GetThreadStorage(p_Offset)); 15 | } 16 | 17 | template 18 | T *GetModuleStorage(const size_t p_Offset = 0) 19 | { 20 | return *reinterpret_cast(Internal_GetModuleStorage(p_Offset)); 21 | } 22 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Interfaces/Client.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Initializable.hpp" 3 | #include 4 | 5 | namespace AnvilCommon 6 | { 7 | class Engine; 8 | 9 | class Client : 10 | public AnvilCommon::Initializable 11 | { 12 | public: 13 | virtual std::shared_ptr GetEngine() = 0; 14 | }; 15 | } 16 | 17 | extern __declspec(dllexport) std::shared_ptr GetClientInterface(); -------------------------------------------------------------------------------- /AnvilCommon/Source/Interfaces/Engine.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "Initializable.hpp" 9 | 10 | namespace AnvilCommon 11 | { 12 | class Engine : 13 | public Initializable 14 | { 15 | private: 16 | std::map> m_Subsystems; 17 | 18 | public: 19 | virtual uint8_t* ExecutableBase() = 0; 20 | virtual size_t ExecutableSize() = 0; 21 | 22 | template 23 | std::shared_ptr GetSubsystem() 24 | { 25 | auto s_TypeName = std::string(typeid(T).name()); 26 | auto s_Pair = m_Subsystems.find(s_TypeName); 27 | 28 | if (s_Pair == m_Subsystems.end()) 29 | { 30 | auto s_Subsystem = std::make_shared(); 31 | m_Subsystems.insert(std::make_pair(s_TypeName, std::static_pointer_cast(s_Subsystem))); 32 | 33 | return s_Subsystem; 34 | } 35 | 36 | return std::static_pointer_cast(s_Pair->second); 37 | } 38 | }; 39 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Interfaces/Initializable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace AnvilCommon 4 | { 5 | class Initializable 6 | { 7 | public: 8 | virtual bool Init() = 0; 9 | virtual ~Initializable() { } 10 | }; 11 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Utils/Hook.cpp: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | #include 4 | #include "Logger.hpp" 5 | #include "Hook.hpp" 6 | 7 | namespace AnvilCommon::Utils 8 | { 9 | bool operator&(const HookFlags &p_A, const HookFlags &p_B) 10 | { 11 | return (HookFlags)((int32_t)p_A & (int32_t)p_B) != HookFlags::None; 12 | } 13 | 14 | Hook::Hook() : 15 | m_Offset(0), m_Flags(HookFlags::None) 16 | { 17 | m_OriginalData.resize(5); 18 | memcpy(m_OriginalData.data(), (uint8_t *)Internal_GetModuleStorage() + m_Offset, m_OriginalData.size()); 19 | } 20 | 21 | Hook::Hook(const size_t p_Offset, void *p_DestFunc, const HookFlags &p_Flags, const std::initializer_list &p_Reset) 22 | : m_Offset(p_Offset), m_DestFunc(p_DestFunc), m_Flags(p_Flags), m_OriginalData(p_Reset) 23 | { 24 | if (m_OriginalData.size() <= 0) 25 | { 26 | m_OriginalData.resize(((m_Flags & HookFlags::IsJmpIfEqual) ? 6 : 5)); 27 | memcpy(m_OriginalData.data(), (uint8_t *)Internal_GetModuleStorage() + m_Offset, m_OriginalData.size()); 28 | } 29 | } 30 | 31 | bool WriteCall(void *p_Address, void *p_NewFunction) 32 | { 33 | DWORD temp; 34 | DWORD temp2; 35 | uint8_t tempJMP[5] = { 0xE8, 0x90, 0x90, 0x90, 0x90 }; 36 | uint32_t JMPSize = ((uint32_t)p_NewFunction - (uint32_t)p_Address - 5); 37 | 38 | if (!VirtualProtect(p_Address, 5, PAGE_READWRITE, &temp)) 39 | { 40 | std::stringstream ss; 41 | ss << "Failed to set protection on memory address " << std::hex << p_Address; 42 | 43 | WriteLog("ERROR: %s", ss.str().c_str()); 44 | 45 | return false; 46 | } 47 | 48 | memcpy(&tempJMP[1], &JMPSize, 4); 49 | memcpy(p_Address, tempJMP, 5); 50 | VirtualProtect(p_Address, 5, temp, &temp2); 51 | 52 | return true; 53 | } 54 | 55 | bool WriteVirtual(void *p_Address, void *p_NewFunction) 56 | { 57 | DWORD temp; 58 | DWORD temp2; 59 | 60 | if (!VirtualProtect(p_Address, 4, PAGE_READWRITE, &temp)) 61 | { 62 | std::stringstream ss; 63 | ss << "Failed to set protection on memory address " << std::hex << (void*)p_Address; 64 | 65 | WriteLog("ERROR: %s", ss.str().c_str()); 66 | 67 | return false; 68 | } 69 | else 70 | { 71 | *(uint32_t *)p_Address = (uint32_t)p_NewFunction; 72 | VirtualProtect(p_Address, 4, temp, &temp2); 73 | } 74 | 75 | return true; 76 | } 77 | 78 | bool WriteJump(void *p_Address, void *p_NewFunction, const HookFlags &p_Flags) 79 | { 80 | DWORD temp; 81 | DWORD temp2; 82 | uint8_t tempJMP[5] = { 0xE9, 0x90, 0x90, 0x90, 0x90 }; 83 | uint8_t tempJE[6] = { 0x0F, 0x84, 0x90, 0x90, 0x90, 0x90 }; 84 | uint32_t patchSize = ((p_Flags & HookFlags::IsJmpIfEqual) || (p_Flags & HookFlags::IsJmpIfNotEqual)) ? 6 : 5; 85 | uint32_t JMPSize = ((uint32_t)p_NewFunction - (uint32_t)p_Address - patchSize); 86 | 87 | if (!VirtualProtect(p_Address, patchSize, PAGE_READWRITE, &temp)) 88 | { 89 | std::stringstream ss; 90 | ss << "Failed to set protection on memory address " << std::hex << p_Address; 91 | OutputDebugString(ss.str().c_str()); 92 | return false; 93 | } 94 | 95 | if (p_Flags & HookFlags::IsJmpIfEqual || p_Flags & HookFlags::IsJmpIfNotEqual) 96 | { 97 | if (p_Flags & HookFlags::IsJmpIfNotEqual) 98 | tempJE[1] = 0x85; 99 | 100 | memcpy(&tempJE[2], &JMPSize, 4); 101 | memcpy(p_Address, tempJE, 6); 102 | } 103 | else 104 | { 105 | memcpy(&tempJMP[1], &JMPSize, 4); 106 | memcpy(p_Address, tempJMP, 5); 107 | } 108 | 109 | VirtualProtect(p_Address, patchSize, temp, &temp2); 110 | 111 | return true; 112 | } 113 | 114 | bool Hook::Apply(const bool p_Reset, void *p_BaseAddress) const 115 | { 116 | if (p_Reset) 117 | return Reset(p_BaseAddress); 118 | 119 | if (m_Flags & HookFlags::IsCall) 120 | return WriteCall((uint8_t *)p_BaseAddress + m_Offset, m_DestFunc); 121 | else if (m_Flags & HookFlags::IsVirtual) 122 | return WriteVirtual((uint8_t *)p_BaseAddress + m_Offset, m_DestFunc); 123 | else 124 | return WriteJump((uint8_t *)p_BaseAddress + m_Offset, m_DestFunc, m_Flags); 125 | } 126 | 127 | bool Hook::Reset(void *p_Offset) const 128 | { 129 | if (m_OriginalData.size()) 130 | memcpy((uint8_t *)p_Offset + m_Offset, m_OriginalData.data(), m_OriginalData.size()); 131 | 132 | return true; 133 | } 134 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Utils/Hook.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "Globals.hpp" 5 | 6 | namespace AnvilCommon::Utils 7 | { 8 | enum class HookFlags : int32_t 9 | { 10 | None, 11 | IsCall = 1 << 0, 12 | IsVirtual = 1 << 1, 13 | IsJmpIfEqual = 1 << 2, 14 | IsJmpIfNotEqual = 1 << 3 15 | }; 16 | 17 | bool operator&(const HookFlags &p_A, const HookFlags &p_B); 18 | 19 | class Hook 20 | { 21 | public: 22 | Hook(); 23 | Hook(const size_t p_Offset, void *p_DestFunc, const HookFlags &p_Flags = HookFlags::None, const std::initializer_list &p_Reset = {}); 24 | 25 | bool Apply(const bool p_Reset = false, void *p_Offset = Internal_GetModuleStorage()) const; 26 | bool Reset(void *p_Offset = Internal_GetModuleStorage()) const; 27 | 28 | private: 29 | size_t m_Offset; 30 | void* m_DestFunc; 31 | HookFlags m_Flags; 32 | std::vector m_OriginalData; 33 | }; 34 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Utils/Logger.cpp: -------------------------------------------------------------------------------- 1 | #include "Logger.hpp" 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace AnvilCommon::Utils; 10 | 11 | std::shared_ptr Logger::GetInstance() 12 | { 13 | static auto s_Instance = std::make_shared(); 14 | return s_Instance; 15 | } 16 | 17 | bool Logger::Init() 18 | { 19 | auto s_Version = AnvilCommon::g_BuildInfo; 20 | 21 | #if _DEBUG 22 | m_Debug = true; 23 | #else 24 | m_Debug = Util::HasCommandLine("-debug"); 25 | #endif 26 | 27 | try 28 | { 29 | // Try to open the log file if one exists and append to it 30 | m_Stream.open("anvil-runtime.log", std::ofstream::out | std::ofstream::app); 31 | } 32 | catch (std::exception& p_Exception) 33 | { 34 | WriteLog("Could not create log file %s.", p_Exception.what()); 35 | } 36 | 37 | WriteLog("\r\n\r\nAnvil Init: %s", s_Version.c_str()); 38 | 39 | InitConsole(s_Version); 40 | 41 | return true; 42 | } 43 | 44 | bool Logger::InitConsole(std::string p_Title) 45 | { 46 | if (!m_Debug) 47 | return true; 48 | 49 | if (!AllocConsole()) 50 | return false; 51 | 52 | // Set the console title 53 | SetConsoleTitle(p_Title.c_str()); 54 | 55 | // Save our console handle for use later 56 | m_ConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); 57 | 58 | return true; 59 | } 60 | 61 | bool Logger::InternalWriteLog(char* p_Function, int32_t p_Line, char* p_Format, ...) 62 | { 63 | if (!m_Debug) 64 | return true; 65 | 66 | va_list s_Args; 67 | va_start(s_Args, p_Format); 68 | 69 | auto s_FinalLength = _vscprintf(p_Format, s_Args) + 1; 70 | 71 | std::vector s_FinalString; 72 | s_FinalString.resize(s_FinalLength); 73 | fill(s_FinalString.begin(), s_FinalString.end(), 0); 74 | 75 | 76 | vsprintf_s(s_FinalString.data(), s_FinalLength, p_Format, s_Args); 77 | 78 | va_end(s_Args); 79 | 80 | std::stringstream s_Stream; 81 | s_Stream << "[" << p_Function << " : " << p_Line << "] " << s_FinalString.data() << "\r\n"; 82 | 83 | auto s_OutputString = s_Stream.str(); 84 | 85 | // Output to the console first 86 | auto s_OutputLength = 0; 87 | if (m_ConsoleHandle && m_ConsoleHandle != INVALID_HANDLE_VALUE) 88 | WriteConsole(m_ConsoleHandle, s_OutputString.c_str(), s_OutputString.length(), reinterpret_cast(&s_OutputLength), nullptr); 89 | 90 | // Try to log to file 91 | if (!m_Stream.is_open()) 92 | return false; 93 | 94 | // Lock 95 | m_Lock.lock(); 96 | 97 | // Write to our file stream 98 | m_Stream << s_OutputString.c_str(); 99 | m_Stream.flush(); 100 | 101 | // Release the lock 102 | m_Lock.unlock(); 103 | 104 | return true; 105 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Utils/Logger.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define WriteLog(p_Format, ...) AnvilCommon::Utils::Logger::GetInstance()->InternalWriteLog(__FUNCTION__, __LINE__, p_Format, __VA_ARGS__); 8 | 9 | namespace AnvilCommon::Utils 10 | { 11 | class Logger : 12 | public Initializable 13 | { 14 | private: 15 | std::mutex m_Lock; 16 | std::ofstream m_Stream; 17 | void* m_ConsoleHandle; 18 | bool m_Debug; 19 | 20 | public: 21 | static std::shared_ptr GetInstance(); 22 | 23 | virtual bool Init(); 24 | 25 | bool InitConsole(std::string p_Title); 26 | bool InternalWriteLog(char* p_Function, int32_t p_line, char* p_Format, ...); 27 | }; 28 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Utils/Patch.cpp: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | #include "Utils\Logger.hpp" 4 | #include "Patch.hpp" 5 | 6 | namespace AnvilCommon::Utils 7 | { 8 | Patch::Patch() 9 | : m_Offset(0) 10 | { 11 | } 12 | 13 | Patch::Patch(const size_t p_Offset, const std::initializer_list &p_PatchData, const std::initializer_list &p_OriginalData) 14 | : m_Offset(p_Offset), m_PatchData(p_PatchData), m_OriginalData(p_OriginalData) 15 | { 16 | } 17 | 18 | Patch::Patch(const size_t p_Offset, const std::initializer_list &p_PatchData, void *p_BaseAddress) 19 | : m_Offset(p_Offset), m_PatchData(p_PatchData) 20 | { 21 | m_OriginalData.resize(m_PatchData.size()); 22 | memcpy(m_OriginalData.data(), (uint8_t *)p_BaseAddress + m_Offset, m_OriginalData.size()); 23 | } 24 | 25 | Patch::Patch(const size_t p_Offset, const uint8_t p_Value, const size_t p_Length, void *p_BaseAddress) 26 | : m_Offset(p_Offset) 27 | { 28 | m_PatchData.resize(p_Length); 29 | std::fill(m_PatchData.begin(), m_PatchData.end(), p_Value); 30 | 31 | m_OriginalData.resize(m_PatchData.size()); 32 | memcpy(m_OriginalData.data(), (uint8_t *)p_BaseAddress + p_Offset, m_OriginalData.size()); 33 | } 34 | 35 | bool Patch::NopFill(const size_t p_Offset, const size_t p_Length, void *p_BaseAddress) 36 | { 37 | if (p_Length <= 0) 38 | { 39 | WriteLog("invalid patch data."); 40 | return false; 41 | } 42 | 43 | // Hold our previous protections 44 | auto s_Protection = 0; 45 | auto *s_Address = (uint8_t *)p_BaseAddress + p_Offset; 46 | // Change the protection so we can write to the executable without crashing 47 | auto s_Ret = VirtualProtect(s_Address, p_Length, PAGE_EXECUTE_READWRITE, reinterpret_cast(&s_Protection)); 48 | if (!s_Ret) 49 | { 50 | WriteLog("could not change protection to patch address %p (%x).", s_Address, GetLastError()); 51 | return false; 52 | } 53 | 54 | WriteLog("changed protection of %x with a length of %x.", s_Address, p_Length); 55 | 56 | // Copy our patch over 57 | memset(s_Address, 0x90, p_Length); 58 | 59 | // Change the protections back 60 | s_Ret = VirtualProtect(s_Address, p_Length, s_Protection, reinterpret_cast(&s_Protection)); 61 | if (!s_Ret) 62 | { 63 | WriteLog("could not change protection back to default for address %p, be warned.", s_Address); 64 | return false; 65 | } 66 | 67 | // Patch succcessfully applied 68 | return true; 69 | } 70 | 71 | bool Patch::Apply(const bool p_Reset, void *p_BaseAddress) const 72 | { 73 | if (p_Reset) 74 | return Reset(p_BaseAddress); 75 | 76 | auto s_Length = m_PatchData.size(); 77 | 78 | if (s_Length <= 0) 79 | { 80 | WriteLog("invalid patch data."); 81 | return false; 82 | } 83 | 84 | // Hold our previous protections 85 | auto s_Protection = 0; 86 | auto *s_Address = (uint8_t *)p_BaseAddress + m_Offset; 87 | // Change the protection so we can write to the executable without crashing 88 | auto s_Ret = VirtualProtect(s_Address, s_Length, PAGE_EXECUTE_READWRITE, reinterpret_cast(&s_Protection)); 89 | if (!s_Ret) 90 | { 91 | WriteLog("could not change protection to patch address %p (%x).", s_Address, GetLastError()); 92 | return false; 93 | } 94 | 95 | WriteLog("changed protection of %x with a length of %x.", s_Address, s_Length); 96 | 97 | // Copy our patch over 98 | s_Ret = memcpy_s(s_Address, s_Length, m_PatchData.data(), s_Length); 99 | if (s_Ret) 100 | { 101 | WriteLog("could not write patch to address %p.", s_Address); 102 | return false; 103 | } 104 | 105 | // Change the protections back 106 | s_Ret = VirtualProtect(s_Address, s_Length, s_Protection, reinterpret_cast(&s_Protection)); 107 | if (!s_Ret) 108 | { 109 | WriteLog("could not change protection back to default for address %p, be warned.", s_Address); 110 | return false; 111 | } 112 | 113 | // Patch succcessfully applied 114 | return true; 115 | } 116 | 117 | bool Patch::Reset(void *p_BaseAddress) const 118 | { 119 | auto s_Length = m_OriginalData.size(); 120 | 121 | if (s_Length <= 0) 122 | { 123 | WriteLog("invalid patch data."); 124 | return false; 125 | } 126 | 127 | // Hold our previous protections 128 | auto s_Protection = 0; 129 | auto *s_Address = (uint8_t *)p_BaseAddress + m_Offset; 130 | // Change the protection so we can write to the executable without crashing 131 | auto s_Ret = VirtualProtect(s_Address, s_Length, PAGE_EXECUTE_READWRITE, reinterpret_cast(&s_Protection)); 132 | if (!s_Ret) 133 | { 134 | WriteLog("could not change protection to patch address %p (%x).", s_Address, GetLastError()); 135 | return false; 136 | } 137 | 138 | WriteLog("changed protection of %x with a length of %x.", s_Address, s_Length); 139 | 140 | // Copy our patch over 141 | s_Ret = memcpy_s(s_Address, s_Length, m_OriginalData.data(), s_Length); 142 | if (s_Ret) 143 | { 144 | WriteLog("could not write patch to address %p.", s_Address); 145 | return false; 146 | } 147 | 148 | // Change the protections back 149 | s_Ret = VirtualProtect(s_Address, s_Length, s_Protection, reinterpret_cast(&s_Protection)); 150 | if (!s_Ret) 151 | { 152 | WriteLog("could not change protection back to default for address %p, be warned.", s_Address); 153 | return false; 154 | } 155 | 156 | // Patch succcessfully applied 157 | return true; 158 | } 159 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Utils/Patch.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "Globals.hpp" 7 | 8 | namespace AnvilCommon::Utils 9 | { 10 | class Patch 11 | { 12 | public: 13 | Patch(); 14 | Patch(const size_t p_Offset, const std::initializer_list &p_PatchData, const std::initializer_list &p_OriginalData); 15 | Patch(const size_t p_Offset, const std::initializer_list &p_PatchData, void *p_BaseAddress = Internal_GetModuleStorage()); 16 | Patch(const size_t p_Offset, const uint8_t p_Value, const size_t p_Length = 1, void *p_BaseAddress = Internal_GetModuleStorage()); 17 | 18 | static bool NopFill(const size_t p_Offset, const size_t p_Length = 1, void *p_BaseAddress = Internal_GetModuleStorage()); 19 | 20 | bool Apply(const bool p_Reset = false, void *p_BaseAddress = Internal_GetModuleStorage()) const; 21 | bool Reset(void *p_BaseAddress = Internal_GetModuleStorage()) const; 22 | 23 | private: 24 | size_t m_Offset; 25 | std::vector m_PatchData; 26 | std::vector m_OriginalData; 27 | }; 28 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Utils/Util.cpp: -------------------------------------------------------------------------------- 1 | #include "Util.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #pragma comment(lib, "psapi.lib") 12 | 13 | using namespace AnvilCommon::Utils; 14 | 15 | bool Util::HasCommandLine(std::string p_Command) 16 | { 17 | std::wstring s_Command(p_Command.begin(), p_Command.end()); 18 | 19 | wchar_t** s_ArgList = nullptr; 20 | int s_ArgCount = 0; 21 | 22 | s_ArgList = CommandLineToArgvW(GetCommandLineW(), &s_ArgCount); 23 | if (!s_ArgList) 24 | return false; 25 | 26 | for (auto i = 0; i < s_ArgCount; ++i) 27 | if (std::wstring(s_ArgList[i]) == s_Command) 28 | return true; 29 | 30 | return false; 31 | } 32 | 33 | bool Util::PatchAddressInMemory(const size_t p_Offset, const std::string &p_HexString, const int32_t p_Length) 34 | { 35 | return PatchAddressInMemory(reinterpret_cast(p_Offset), p_HexString, p_Length); 36 | } 37 | 38 | bool Util::PatchAddressInMemory(void *p_Address, const std::string &p_HexString, const int32_t p_Length) 39 | { 40 | // Get the length of our patch 41 | auto s_Length = (p_Length == -1 ? p_HexString.length() : p_Length); 42 | if (s_Length <= 0) 43 | { 44 | WriteLog("invalid patch data."); 45 | return false; 46 | } 47 | 48 | // Hold our previous protections 49 | auto s_Protection = 0; 50 | 51 | // Change the protection so we can write to the executable without crashing 52 | auto s_Ret = VirtualProtect(reinterpret_cast(p_Address), s_Length, PAGE_EXECUTE_READWRITE, reinterpret_cast(&s_Protection)); 53 | if (!s_Ret) 54 | { 55 | WriteLog("could not change protection to patch address %p (%x).", p_Address, GetLastError()); 56 | return false; 57 | } 58 | 59 | WriteLog("changed protection of %x with a length of %x.", p_Address, s_Length); 60 | 61 | // Copy our patch over 62 | s_Ret = memcpy_s(reinterpret_cast(p_Address), s_Length, p_HexString.c_str(), s_Length); 63 | if (s_Ret) 64 | { 65 | WriteLog("could not write patch to address %p.", p_Address); 66 | return false; 67 | } 68 | 69 | // Change the protections back 70 | s_Ret = VirtualProtect(reinterpret_cast(p_Address), s_Length, s_Protection, reinterpret_cast(&s_Protection)); 71 | if (!s_Ret) 72 | { 73 | WriteLog("could not change protection back to default for address %p, be warned.", p_Address); 74 | return false; 75 | } 76 | 77 | // Patch succcessfully applied 78 | return true; 79 | } 80 | 81 | bool Util::PatchAddressInFile(const size_t p_Offset, const std::string &p_HexString, const int32_t p_Length) 82 | { 83 | return PatchAddressInFile(reinterpret_cast(p_Offset), p_HexString, p_Length); 84 | } 85 | 86 | bool Util::PatchAddressInFile(void *p_Address, const std::string &p_HexString, const int32_t p_Length) 87 | { 88 | // Ensure that the address is valid 89 | if (!p_Address) 90 | { 91 | WriteLog("could not patch, invalid address passed."); 92 | return false; 93 | } 94 | 95 | auto s_BaseAddress = reinterpret_cast(GetModuleHandle(nullptr)); 96 | auto s_Address = s_BaseAddress + reinterpret_cast(p_Address); 97 | 98 | return PatchAddressInMemory(s_Address, p_HexString, p_Length); 99 | } 100 | 101 | bool Util::PatchAddress(const size_t p_Offset, const std::string &p_HexString, const int32_t p_Length, bool p_InMemory) 102 | { 103 | if (p_InMemory) 104 | return PatchAddressInMemory(p_Offset, p_HexString, p_Length); 105 | 106 | return PatchAddressInFile(p_Offset, p_HexString, p_Length); 107 | } 108 | 109 | bool Util::PatchAddress(void *p_Address, const std::string &p_HexString, const int32_t p_Length, bool p_InMemory) 110 | { 111 | if (p_InMemory) 112 | return PatchAddressInMemory(p_Address, p_HexString, p_Length); 113 | 114 | return PatchAddressInFile(p_Address, p_HexString, p_Length); 115 | } 116 | 117 | bool Util::ResumeAllThreads() 118 | { 119 | auto s_ThreadSnap = INVALID_HANDLE_VALUE; 120 | 121 | THREADENTRY32 s_Entry; 122 | ZeroMemory(&s_Entry, sizeof(s_Entry)); 123 | s_Entry.dwSize = sizeof(THREADENTRY32); 124 | 125 | // Snapshot all running threads 126 | s_ThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); 127 | if (s_ThreadSnap == INVALID_HANDLE_VALUE) 128 | return false; 129 | 130 | // Get information about the first thread 131 | if (!Thread32First(s_ThreadSnap, &s_Entry)) 132 | { 133 | CloseHandle(s_ThreadSnap); 134 | 135 | WriteLog("Could not get the thread snapshot (%x).", GetLastError()); 136 | return false; 137 | } 138 | 139 | auto s_CurrentProcess = GetCurrentProcessId(); 140 | do 141 | { 142 | if (s_Entry.th32OwnerProcessID == s_CurrentProcess) 143 | { 144 | auto l_ThreadHandle = OpenThread(THREAD_SUSPEND_RESUME, FALSE, s_Entry.th32ThreadID); 145 | if (l_ThreadHandle == INVALID_HANDLE_VALUE) 146 | continue; 147 | 148 | //WriteLog("Resuming thread : %x.", s_Entry.th32ThreadID); 149 | 150 | ResumeThread(l_ThreadHandle); 151 | 152 | CloseHandle(l_ThreadHandle); 153 | } 154 | } while (Thread32Next(s_ThreadSnap, &s_Entry)); 155 | 156 | CloseHandle(s_ThreadSnap); 157 | 158 | WriteLog("All threads resumed successfully."); 159 | return true; 160 | } -------------------------------------------------------------------------------- /AnvilCommon/Source/Utils/Util.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace AnvilCommon::Utils 5 | { 6 | class Util 7 | { 8 | public: 9 | static bool HasCommandLine(std::string p_Command); 10 | 11 | static bool PatchAddressInMemory(const size_t p_Offset, const std::string &p_HexString, const int32_t p_Length); 12 | static bool PatchAddressInMemory(void *p_Address, const std::string &p_HexString, const int32_t p_Length); 13 | static bool PatchAddressInFile(const size_t p_Offset, const std::string &p_HexString, const int32_t p_Length); 14 | static bool PatchAddressInFile(void *p_Address, const std::string &p_HexString, const int32_t p_Length); 15 | static bool PatchAddress(const size_t p_Offset, const std::string &p_HexString, const int32_t p_Length, bool p_InMemory = false); 16 | static bool PatchAddress(void *p_Address, const std::string &p_HexString, const int32_t p_Length, bool p_InMemory = false); 17 | 18 | static bool ResumeAllThreads(); 19 | 20 | template 21 | static int32_t CountBits(T p_Value) 22 | { 23 | int32_t result = 0; 24 | 25 | while (p_Value != 0) 26 | { 27 | p_Value >>= 1; 28 | result++; 29 | } 30 | 31 | return result; 32 | } 33 | }; 34 | } -------------------------------------------------------------------------------- /AnvilEldorado/Depends/Library/libMinHook-x86-v140-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnvilOnline/AnvilClient/9b7751d9583d7221fd9c9f1b864f27e7ff9fcf79/AnvilEldorado/Depends/Library/libMinHook-x86-v140-mt.lib -------------------------------------------------------------------------------- /AnvilEldorado/Depends/Library/libMinHook-x86-v140-mtd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnvilOnline/AnvilClient/9b7751d9583d7221fd9c9f1b864f27e7ff9fcf79/AnvilEldorado/Depends/Library/libMinHook-x86-v140-mtd.lib -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Cache/StringIDCacheHeader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Cache 5 | { 6 | struct StringIDCacheHeader 7 | { 8 | int32_t Count; 9 | int32_t Size; 10 | }; 11 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/BitStream.cpp: -------------------------------------------------------------------------------- 1 | #include "BitStream.hpp" 2 | 3 | namespace Blam::Data 4 | { 5 | BitStream::BitStream() 6 | : Start(nullptr), End(nullptr), Unknown14(nullptr), CurrentPointer(nullptr) 7 | { 8 | } 9 | 10 | int BitStream::GetAvailableBits() const 11 | { 12 | return sizeof(Window) * 8 - WindowBitsUsed; 13 | } 14 | 15 | bool BitStream::BitsAvailable(const int32_t p_Bits) const 16 | { 17 | return p_Bits <= GetAvailableBits(); 18 | } 19 | 20 | bool BitStream::ReadBit() 21 | { 22 | return reinterpret_cast(0x558570)(this); 23 | } 24 | 25 | uint64_t BitStream::ReadBits(const int32_t p_Bits) 26 | { 27 | if (p_Bits <= 32) 28 | { 29 | return reinterpret_cast(0x5589A0)(this, p_Bits); 30 | } 31 | 32 | return reinterpret_cast(0x559160)(this, p_Bits); 33 | } 34 | 35 | bool BitStream::ReadBool() 36 | { 37 | return ReadBit(); 38 | } 39 | 40 | void BitStream::ReadBlock(const size_t bits, uint8_t *out) 41 | { 42 | reinterpret_cast(0x558740)(this, out, bits); 43 | } 44 | 45 | void BitStream::WriteBits(const uint64_t p_Value, const int32_t p_Bits) 46 | { 47 | if (BitsAvailable(p_Bits)) 48 | { 49 | Position += p_Bits; 50 | WindowBitsUsed += p_Bits; 51 | Window <<= p_Bits; 52 | Window |= p_Value & (0xFFFFFFFFFFFFFFFF >> (64 - p_Bits)); 53 | } 54 | else 55 | { 56 | return reinterpret_cast(0x559EB0)(this, p_Value, p_Bits); 57 | } 58 | } 59 | 60 | void BitStream::WriteBool(const bool p_Value) 61 | { 62 | WriteUnsigned(p_Value, 1); 63 | } 64 | 65 | void BitStream::WriteBlock(const size_t p_Bits, const uint8_t *p_Data) 66 | { 67 | reinterpret_cast(0x55A000)(this, p_Data, p_Bits, 0); 68 | } 69 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/BitStream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Utils\Util.hpp" 4 | 5 | namespace Blam::Data 6 | { 7 | struct BitStream 8 | { 9 | uint8_t *Start; 10 | uint8_t *End; 11 | uint32_t Size; 12 | uint32_t UnknownC; 13 | uint32_t Unknown10; 14 | void *Unknown14; 15 | uint32_t Unknown18; 16 | uint32_t Position; 17 | uint64_t Window; 18 | int WindowBitsUsed; 19 | uint8_t *CurrentPointer; 20 | uint32_t Unknown30; 21 | uint8_t Unknown34[100]; 22 | uint32_t Unknown98; 23 | uint32_t Unknown9C; 24 | 25 | BitStream(); 26 | 27 | int GetAvailableBits() const; 28 | bool BitsAvailable(const int32_t p_Bits) const; 29 | 30 | bool ReadBit(); 31 | uint64_t ReadBits(const int32_t p_Bits); 32 | 33 | bool ReadBool(); 34 | 35 | template 36 | T ReadUnsigned(const int32_t p_Bits) 37 | { 38 | return static_cast(ReadBits(p_Bits)); 39 | } 40 | 41 | template 42 | T ReadUnsigned(const T p_Minimum, const T p_Maximum) 43 | { 44 | return static_cast(ReadUnsigned(AnvilCommon::Utils::Util::CountBits(p_Maximum - p_Minimum))); 45 | } 46 | 47 | void ReadBlock(const size_t p_Bits, uint8_t *p_Out); 48 | 49 | template 50 | bool ReadString(CharType(&p_String)[MaximumSize]) 51 | { 52 | // Length 53 | auto s_Length = ReadUnsigned(0U, MaximumSize - 1); 54 | if (s_Length >= MaximumSize) 55 | return false; 56 | 57 | // String 58 | memset(&p_String, 0, MaximumSize * sizeof(CharType)); 59 | ReadBlock(s_Length * sizeof(CharType) * 8, reinterpret_cast(&p_String)); 60 | return true; 61 | } 62 | 63 | void WriteBits(const uint64_t p_Value, const int32_t p_Bits); 64 | 65 | void WriteBool(const bool p_Value); 66 | 67 | template 68 | void WriteUnsigned(const T p_Value, const int32_t p_Bits) 69 | { 70 | WriteBits(static_cast(p_Value), p_Bits); 71 | } 72 | 73 | template 74 | void WriteUnsigned(const T p_Value, const T p_Minimum, const T p_Maximum) 75 | { 76 | WriteUnsigned(p_Value - p_Minimum, AnvilCommon::Utils::Util::CountBits(p_Maximum - p_Minimum)); 77 | } 78 | 79 | void WriteBlock(const size_t p_Bits, const uint8_t *p_Data); 80 | 81 | template 82 | void WriteString(const CharType(&p_String)[MaximumSize]) 83 | { 84 | // Compute length 85 | size_t s_Length = 0; 86 | while (s_Length < MaximumSize - 1 && str[s_Length]) 87 | s_Length++; 88 | 89 | // Write length 90 | WriteUnsigned(s_Length, 0U, MaximumSize - 1); 91 | 92 | // Write string 93 | WriteBlock(s_Length * sizeof(CharType) * 8, reinterpret_cast(&p_String)); 94 | } 95 | }; 96 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/DataArray.cpp: -------------------------------------------------------------------------------- 1 | #include "DataArray.hpp" 2 | 3 | using namespace Blam::Data; 4 | 5 | DataArrayBase::DataArrayBase() 6 | : Allocator(nullptr), Data(nullptr) 7 | { 8 | } 9 | 10 | DatumBase *DataArrayBase::Get(const DatumIndex &p_Index) const 11 | { 12 | return reinterpret_cast(0x55B6D0)(this, p_Index); 13 | } 14 | 15 | DatumBase *DataArrayBase::GetAddress(const DatumIndex &p_Index) const 16 | { 17 | return reinterpret_cast(static_cast(Data) + p_Index.Index() * DatumSize); 18 | } 19 | 20 | DatumBase *DataIteratorBase::Next() 21 | { 22 | return reinterpret_cast(0x55AE30)(this); 23 | } 24 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/DataPoolBase.cpp: -------------------------------------------------------------------------------- 1 | #include "DataPoolBase.hpp" 2 | 3 | using namespace Blam::Data; 4 | 5 | DataPoolBase::DataPoolBase() 6 | : Allocator(nullptr) 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/DataPoolBase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Data 5 | { 6 | struct DataPoolBase 7 | { 8 | int32_t Signature; 9 | char Name[0x20]; 10 | void** Allocator; 11 | int32_t Size; 12 | int32_t FreeSize; 13 | int32_t Padding; 14 | int32_t Unknown52; 15 | int32_t Unknown56; 16 | uint16_t Unknown60; 17 | uint8_t Unknown62; 18 | uint8_t Unknown63; 19 | int32_t Unknown64; 20 | 21 | DataPoolBase(); 22 | }; 23 | static_assert(sizeof(DataPoolBase) == 0x44, "Blam::Data::DataPoolBase"); 24 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/DatumBase.cpp: -------------------------------------------------------------------------------- 1 | #include "DatumBase.hpp" 2 | 3 | using namespace Blam::Data; 4 | 5 | const DatumBase DatumBase::Null = { 0xFFFF }; 6 | 7 | DatumBase::DatumBase() 8 | : DatumBase(DatumBase::Null.Salt) 9 | { 10 | } 11 | 12 | DatumBase::DatumBase(const uint16_t p_Salt) 13 | : Salt(p_Salt) 14 | { 15 | } 16 | 17 | bool DatumBase::operator==(const DatumBase &p_Other) const 18 | { 19 | return Salt == p_Other.Salt; 20 | } 21 | 22 | bool DatumBase::operator!=(const DatumBase &p_Other) const 23 | { 24 | return !(*this == p_Other); 25 | } 26 | 27 | DatumBase::operator uint16_t() const 28 | { 29 | return Salt; 30 | } 31 | 32 | DatumBase::operator bool() const 33 | { 34 | return *this != Null; 35 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/DatumBase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Data 5 | { 6 | struct DatumBase 7 | { 8 | static const DatumBase Null; 9 | 10 | uint16_t Salt; 11 | 12 | DatumBase(); 13 | DatumBase(const uint16_t p_Salt); 14 | 15 | bool operator==(const DatumBase &p_Other) const; 16 | bool operator!=(const DatumBase &p_Other) const; 17 | 18 | explicit operator uint16_t() const; 19 | 20 | explicit operator bool() const; 21 | }; 22 | static_assert(sizeof(DatumBase) == 0x2, "Blam::Data::DatumBase"); 23 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/DatumIndex.cpp: -------------------------------------------------------------------------------- 1 | #include "DatumIndex.hpp" 2 | 3 | using namespace Blam::Data; 4 | 5 | const DatumIndex DatumIndex::Null = { 0xFFFFFFFF }; -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/DatumIndex.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Data 5 | { 6 | // A unique handle used to refer to data. 7 | struct DatumIndex 8 | { 9 | // Represents a null datum index. 10 | static const DatumIndex Null; 11 | 12 | typedef uint16_t TSalt; // Type of a salt value 13 | typedef uint16_t TIndex; // Type of an index value 14 | 15 | // Creates a null datum index. 16 | DatumIndex() : Value(0xFFFFFFFF) { } 17 | 18 | // Creates a datum index from a handle. 19 | DatumIndex(uint32_t handle) : Value(handle) { } 20 | 21 | // Creates a datum index from a salt and an index. 22 | DatumIndex(TSalt salt, TIndex index) 23 | { 24 | Value = (salt << 16) | index; 25 | } 26 | 27 | // The value of the datum index as a 32-bit integer. 28 | uint32_t Value; 29 | 30 | // Gets the datum index's salt value. 31 | TSalt Salt() const { return Value >> 16; } 32 | 33 | // Gets the datum index's index value. 34 | TIndex Index() const { return Value & 0xFFFF; } 35 | 36 | bool operator==(const DatumIndex other) const { return Value == other.Value; } 37 | bool operator!=(const DatumIndex other) const { return !(*this == other); } 38 | operator uint32_t() const { return Value; } 39 | operator bool() const { return *this != Null; } 40 | }; 41 | static_assert(sizeof(DatumIndex) == 4, "Invalid DatumIndex size"); 42 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/LruvCacheBase.cpp: -------------------------------------------------------------------------------- 1 | #include "LruvCacheBase.hpp" 2 | 3 | using namespace Blam::Data; 4 | 5 | LruvCacheBase::LruvCacheBase() 6 | : Unknown32(nullptr), Unknown36(nullptr), Unknown40(nullptr), Unknown44(nullptr), Allocator(nullptr) 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Data/LruvCacheBase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Data 5 | { 6 | struct LruvCacheBase 7 | { 8 | char Name[0x20]; 9 | void *Unknown32; 10 | void *Unknown36; 11 | void *Unknown40; 12 | void *Unknown44; 13 | int32_t Unknown48; 14 | int32_t Unknown52; 15 | int32_t Unknown56; 16 | int32_t Unknown60; 17 | int32_t Unknown64; 18 | int32_t Unknown68; 19 | int32_t Unknown72; 20 | int32_t Unknown76; 21 | int32_t Unknown80; 22 | int32_t Unknown84; 23 | int32_t Unknown88; 24 | int32_t Unknown92; 25 | int32_t Unknown96; 26 | int32_t Unknown100; 27 | int32_t Unknown104; 28 | int32_t Unknown108; 29 | int32_t Unknown112; 30 | int32_t Signature; 31 | void **Allocator; 32 | int32_t Unknown124; 33 | int32_t Unknown128; 34 | 35 | LruvCacheBase(); 36 | }; 37 | static_assert(sizeof(LruvCacheBase) == 0x84, "Blam::Data::LruvCacheBase"); 38 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Damage.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Game 5 | { 6 | enum class DamageReportingType : uint8_t 7 | { 8 | GuardiansUnknown, 9 | Guardians, 10 | FallingDamage, 11 | GenericCollision, 12 | ArmorLockCrush, 13 | GenericMelee, 14 | GenericExplosion, 15 | Magnum, 16 | PlasmaPistol, 17 | Needler, 18 | Mauler, 19 | SMG, 20 | PlasmaRifle, 21 | BattleRifle, 22 | CovenantCarbine, 23 | Shotgun, 24 | SniperRifle, 25 | BeamRifle, 26 | AssaultRifle, 27 | Spiker, 28 | FuelRodCannon, 29 | MissilePod, 30 | RocketLauncher, 31 | SpartanLaser, 32 | BruteShot, 33 | Flamethrower, 34 | SentinelGun, 35 | EnergySword, 36 | GravityHammer, 37 | FragGrenade, 38 | PlasmaGrenade, 39 | SpikeGrenade, 40 | FirebombGrenade, 41 | Flag, 42 | Bomb, 43 | BombExplosion, 44 | Ball, 45 | MachinegunTurret, 46 | PlasmaCannon, 47 | PlasmaMortar, 48 | PlasmaTurret, 49 | ShadeTurret, 50 | Banshee, 51 | Ghost, 52 | Mongoose, 53 | Scorpion, 54 | ScorpionGunner, 55 | Spectre, 56 | SpectreGunner, 57 | Warthog, 58 | WarthogGunner, 59 | WarthogGaussTurret, 60 | Wraith, 61 | WraithGunner, 62 | Tank, 63 | Chopper, 64 | Hornet, 65 | Mantis, 66 | Prowler, 67 | SentinelBeam, 68 | SentinelRPG, 69 | Teleporter, 70 | Tripmine, 71 | DMR, 72 | 73 | Count 74 | }; 75 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Events.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "..\Data\DatumIndex.hpp" 4 | #include "..\Tags\TagReference.hpp" 5 | 6 | namespace Blam::Game 7 | { 8 | enum class EventType : int16_t 9 | { 10 | General, 11 | Flavor, 12 | Slayer, 13 | Ctf, 14 | Oddball, 15 | Forge, 16 | Koth, 17 | Vip, 18 | Juggernaut, 19 | Territories, 20 | Assault, 21 | Infection, 22 | Survival, 23 | Wp 24 | }; 25 | 26 | enum class EventAudience : int16_t 27 | { 28 | CausePlayer, 29 | CauseTeam, 30 | EffectPlayer, 31 | EffectTeam, 32 | All 33 | }; 34 | 35 | struct Event 36 | { 37 | EventType Type : 16; 38 | uint32_t NameStringID; 39 | int32_t Unknown8; 40 | int32_t UnknownC; 41 | Data::DatumIndex CausePlayer; 42 | int32_t CauseTeam; 43 | Data::DatumIndex EffectPlayer; 44 | int32_t EffectTeam; 45 | int32_t Unknown20; 46 | int16_t Unknown24; 47 | }; 48 | static_assert(sizeof(Event) == 0x28, "Blam::Game::Event"); 49 | 50 | struct EventDefinition 51 | { 52 | uint16_t Flags; 53 | EventType Type : 16; 54 | uint32_t NameStringID; 55 | EventAudience Audience; 56 | uint16_t UnknownA; 57 | int16_t Team; 58 | uint16_t UnknownE; 59 | uint32_t MessageStringID; 60 | uint32_t MedalStringID; 61 | uint32_t Unknown18; 62 | uint32_t Unknown1C; 63 | uint16_t RequiredField; 64 | uint16_t ExcludedAudience; 65 | uint16_t RequiredField2; 66 | uint16_t ExcludedAudience2; 67 | uint32_t PrimaryStringId; 68 | int32_t PrimaryStringDuration; 69 | uint32_t PluralDisplayStringId; 70 | float SoundDelay; 71 | uint16_t SoundFlags; 72 | uint16_t Unknown3A; 73 | Tags::TagReference LanguageSounds[12]; 74 | uint32_t UnknownFC; 75 | uint32_t Unknown100; 76 | uint32_t Unknown104; 77 | uint32_t Unknown108; 78 | }; 79 | static_assert(sizeof(EventDefinition) == 0x10C, "Blam::Game::EventDefinition"); 80 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Medals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Game 5 | { 6 | enum class MedalType : uint8_t 7 | { 8 | Exterminations, 9 | Perfections, 10 | DoubleKills, 11 | TripleKills, 12 | OverKills, 13 | Killtaculars, 14 | Killtrocities, 15 | Killimanjaros, 16 | Killtastrophes, 17 | Killpocalypses, 18 | Killionaires, 19 | KillingSprees, 20 | KillingFrenzies, 21 | RunningRiots, 22 | Rampages, 23 | Untouchables, 24 | Invincibles, 25 | SniperSprees, 26 | Sharpshooters, 27 | ShotgunSprees, 28 | OpenSeasons, 29 | SplatterSprees, 30 | VehicularManslaughters, 31 | SwordSprees, 32 | SliceNDices, 33 | JuggernautSprees, 34 | Unstoppables, 35 | InfectionSprees, 36 | MMMBrains, 37 | ZombieKillingSprees, 38 | HellsJanitors, 39 | Unknown1, 40 | HailToTheKings, 41 | Bulltrue, 42 | Splatters, 43 | HiJacks, 44 | Skyjacks, 45 | KillsFromTheGrave, 46 | Killjoys, 47 | LaserKills, 48 | Sticks, 49 | Headshots, 50 | Assasinations, 51 | Beatdowns, 52 | Incinerations, 53 | Wheelmans, 54 | BombPlanteds, 55 | KilledBombCarriers, 56 | KilledVIPs, 57 | KilledJuggernauts, 58 | OddballKills, 59 | FlagScores, 60 | KilledFlagCarriers, 61 | 62 | Count 63 | }; 64 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Players/ClientPlayerProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Game::Players 5 | { 6 | struct ClientPlayerProperties 7 | { 8 | wchar_t DisplayName[16]; 9 | int8_t TeamIndex; 10 | int16_t Unknown22; 11 | uint32_t Unknown24; 12 | uint32_t Unknown28; 13 | uint32_t Unknown2C; 14 | }; 15 | static_assert(sizeof(ClientPlayerProperties) == 0x30, "Blam::Game::ClientPlayerProperties"); 16 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Players/PlayerArmor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Game::Players 4 | { 5 | enum class PlayerArmor 6 | { 7 | Helmet = 0, 8 | Chest, 9 | Shoulders, 10 | Arms, 11 | Legs, 12 | Acc, 13 | Pelvis, 14 | 15 | Count 16 | }; 17 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Players/PlayerColor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Game::Players 4 | { 5 | enum class PlayerColor 6 | { 7 | Primary, 8 | Secondary, 9 | Visor, 10 | Lights, 11 | Holo, 12 | 13 | Count 14 | }; 15 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Players/PlayerCustomization.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "PlayerColor.hpp" 5 | #include "PlayerArmor.hpp" 6 | 7 | namespace Blam::Game::Players 8 | { 9 | struct PlayerCustomization 10 | { 11 | uint32_t Colors[(int)PlayerColor::Count]; 12 | uint8_t Armor[(int)PlayerArmor::Count]; 13 | uint32_t Unknown1C; 14 | }; 15 | static_assert(sizeof(PlayerCustomization) == 0x20, "Blam::Game::PlayerCustomization"); 16 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Players/PlayerDatum.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "PlayerProperties.hpp" 5 | 6 | namespace Blam::Game::Players 7 | { 8 | struct PlayerDatum : Data::DatumBase 9 | { 10 | uint8_t Unknown2[0x2E]; 11 | Data::DatumIndex SlaveUnit; 12 | uint8_t Unknown34[0x3C]; 13 | PlayerProperties Properties; 14 | uint8_t Unknown1690[0x1724]; 15 | int16_t SpawnGrenadeSetting; 16 | uint8_t Unknown2DB6[0x152]; 17 | }; 18 | static_assert(sizeof(PlayerDatum) == 0x2F08, "Blam::Game::PlayerDatum"); 19 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Players/PlayerProperties.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "ClientPlayerProperties.hpp" 4 | #include "PlayerCustomization.hpp" 5 | 6 | namespace Blam::Game::Players 7 | { 8 | struct PlayerProperties 9 | { 10 | ClientPlayerProperties ClientProperties; 11 | uint64_t Uid; 12 | wchar_t DisplayName[16]; 13 | int TeamIndex; 14 | uint8_t Unknown5C[0x66C]; 15 | PlayerCustomization Customization; 16 | uint8_t Unknown6E4[0xF38]; 17 | }; 18 | static_assert(sizeof(PlayerProperties) == 0x1620, "Blam::Game::PlayerProperties"); 19 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Stats.cpp: -------------------------------------------------------------------------------- 1 | #include "Stats.hpp" 2 | 3 | namespace Blam::Game 4 | { 5 | int32_t GetKills(const Data::DatumIndex &p_Player) 6 | { 7 | return reinterpret_cast(0x550620)(p_Player); 8 | } 9 | 10 | int32_t GetDeaths(const Data::DatumIndex &p_Player) 11 | { 12 | return reinterpret_cast(0x550580)(p_Player); 13 | } 14 | 15 | int32_t GetAssists(const Data::DatumIndex &p_Player) 16 | { 17 | return reinterpret_cast(0x5504E0)(p_Player); 18 | } 19 | 20 | Stats::PlayerStats GetStats(const size_t p_PlayerIndex) 21 | { 22 | return *reinterpret_cast(0x23F1718 + (p_PlayerIndex * sizeof(Stats::PlayerStats))); 23 | } 24 | 25 | Stats::PlayerKilledPlayerStats GetPVPStats(const size_t p_PlayerIndex) 26 | { 27 | return *reinterpret_cast(0x23F5A98 + (p_PlayerIndex * sizeof(Stats::PlayerKilledPlayerStats))); 28 | } 29 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Stats.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Stats\PlayerStats.hpp" 3 | #include "Stats\PlayerKilledPlayerStats.hpp" 4 | 5 | #include 6 | 7 | namespace Blam::Game 8 | { 9 | int32_t GetKills(const Data::DatumIndex &p_Player); 10 | 11 | int32_t GetDeaths(const Data::DatumIndex &p_Player); 12 | 13 | int32_t GetAssists(const Data::DatumIndex &p_Player); 14 | 15 | Stats::PlayerStats GetStats(const size_t p_PlayerIndex); 16 | 17 | Stats::PlayerKilledPlayerStats GetPVPStats(const size_t p_PlayerIndex); 18 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Stats/PlayerKilledPlayerStats.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PlayerVsStats.hpp" 3 | 4 | namespace Blam::Game::Stats 5 | { 6 | struct PlayerKilledPlayerStats 7 | { 8 | PlayerVsStats StatsAgainstEachPlayer[16]; 9 | }; 10 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Stats/PlayerStats.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "WeaponStats.hpp" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | 10 | namespace Blam::Game::Stats 11 | { 12 | struct PlayerStats 13 | { 14 | uint8_t Unknown0[0xC]; 15 | int16_t Score; 16 | uint16_t Unknown1; 17 | int16_t Kills; 18 | uint16_t Assists; 19 | uint16_t Deaths; 20 | uint16_t Betrayals; 21 | uint16_t Suicides; 22 | uint16_t BestStreak; 23 | uint16_t TimeSpentAlive; 24 | uint8_t Unknown3[0x1A]; 25 | uint16_t KingsKilled; 26 | uint16_t TimeInHill; 27 | uint16_t TimeControllingHill; 28 | uint8_t Unknown4[0x22]; 29 | uint16_t ZombiesKilled; 30 | uint16_t HumansInfected; 31 | uint16_t Unknown5; 32 | uint16_t Medals[(int)MedalType::Count]; 33 | uint8_t Unknown6[0x68]; 34 | WeaponStats WeaponStats[(int)DamageReportingType::Count]; 35 | }; 36 | static_assert(sizeof(PlayerStats) == 0x438, "Blam::Game::PlayerStats"); 37 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Stats/PlayerVsStats.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Game::Stats 5 | { 6 | struct PlayerVsStats 7 | { 8 | uint16_t Kills; 9 | uint16_t KilledBy; 10 | }; 11 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Stats/WeaponStats.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Game::Stats 5 | { 6 | struct WeaponStats 7 | { 8 | uint16_t Initialized; 9 | uint16_t Kills; 10 | uint16_t KilledBy; 11 | uint16_t BetrayalsWith; 12 | uint16_t SuicidesWith; 13 | uint16_t HeadshotsWith; 14 | }; 15 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Game/Variants.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Game 5 | { 6 | enum class GameType : int32_t 7 | { 8 | None, 9 | CTF, 10 | Slayer, 11 | Oddball, 12 | KOTH, 13 | Forge, 14 | VIP, 15 | Juggernaut, 16 | Territories, 17 | Assault, 18 | Infection, 19 | 20 | Count 21 | }; 22 | 23 | enum class GameMode : int32_t 24 | { 25 | Invalid, 26 | Campaign, 27 | Multiplayer, 28 | Mainmenu, 29 | Shared, 30 | 31 | Count 32 | }; 33 | 34 | // 35 | // TODO: Find a better spot for the structures below 36 | // 37 | 38 | struct GameContentHeader 39 | { 40 | uint64_t ID; // not sure about this 41 | wchar_t Name[0x10]; 42 | char Description[0x80]; 43 | char Author[0x10]; 44 | uint32_t Type; 45 | uint32_t Unknown1; // 0 46 | uint32_t Unknown2; // 1 47 | uint32_t Unknown3; // 0 48 | uint32_t Size; // 0xE1F0 for maps, 0x3BC for variants 49 | uint32_t Unknown4; // 0 50 | uint32_t UnknownUnique1; // changes for each item 51 | uint32_t Unknown5; // 0 52 | uint32_t Unknown6; // 0 53 | uint32_t Unknown7; // -1 54 | uint32_t Unknown8; // 0x140 for maps, -1 for variants, 55 | uint64_t Unknown9; // 0 for maps, 4 for variants 56 | uint32_t Unknown10; // -1; 57 | uint32_t Unknown11; // 0; 58 | uint32_t Unknown12; // 0; 59 | uint32_t Unknown13; // 0; 60 | }; 61 | 62 | struct GameContentItem 63 | { 64 | uint32_t Index; 65 | uint32_t ItemFlags; 66 | uint32_t ItemType; 67 | uint32_t BaseOffset; 68 | GameContentHeader ContentHeader; 69 | wchar_t FilePath[0x99]; 70 | }; 71 | 72 | struct GameVariant 73 | { 74 | GameType Engine : 32; 75 | float Unknown1; 76 | uint8_t Unknown2[0x2C]; 77 | wchar_t Name[0x10]; 78 | char Description[0x80]; 79 | char Author[0x10]; 80 | uint8_t Unknown3[0x40]; 81 | uint8_t TeamGame; 82 | uint8_t RoundTimeLimit; 83 | uint8_t NumberOfRounds; 84 | uint8_t Unknown5; 85 | uint8_t Unknown6; 86 | uint8_t Unknown7; 87 | uint8_t Unknown8; 88 | uint8_t Unknown9; 89 | /* 0xC58 */ uint8_t Unknown10; // default 0xA 90 | uint8_t RespawnTime; 91 | uint8_t Unknown11; // default 5 92 | uint8_t Unknown12; // 0 93 | uint8_t Unknown13; // default 5 94 | uint8_t Unknown14; // 0 95 | uint8_t Unknown15; // 0 96 | uint8_t Unknown16; // 0 97 | /* 0xC60 */ uint8_t Unknown17; // 0 98 | uint8_t Unknown18; // 0 99 | uint8_t Unknown19; // 0 100 | uint8_t Unknown20; // 0 101 | uint8_t Unknown21; // 0 102 | uint8_t Unknown22; // 0 103 | uint8_t Unknown23; // 0 104 | uint8_t Unknown24; // 0 105 | /* 0xC68 */ uint8_t Unknown25; // 0 106 | uint8_t Unknown26; // 0 107 | uint8_t Unknown27; // 0 108 | uint8_t Unknown28; // default 0xFE 109 | uint8_t Unknown29; // default 0xFE 110 | uint8_t Unknown30; // 0 111 | uint8_t Unknown31; // 0 112 | uint8_t Unknown32; // 0 113 | /* 0xC70 */ uint8_t Unknown33; // 0 114 | uint8_t Unknown34; // 0 115 | uint8_t Unknown35; // 0 116 | uint8_t Unknown36; // 0 117 | uint8_t Unknown37; // 0 118 | uint8_t Unknown38; // 0 119 | uint8_t Unknown39; // 0 120 | uint8_t Unknown40; // 0 121 | /* 0xC78 */ uint8_t Unknown41; // 0 122 | uint8_t Unknown42; // 0 123 | uint8_t Unknown43; // 0 124 | uint8_t Unknown44; // 0 125 | uint8_t Unknown45; // 0 126 | uint8_t Unknown46; // default 7 127 | uint8_t Unknown47; // 0 128 | uint8_t Unknown48; // default 1 129 | /* 0xC80 */ uint8_t Unknown49; // 0 130 | uint8_t Unknown50; // default 1 131 | uint8_t Unknown51; // 0 132 | uint8_t Unknown52; // 0 133 | uint8_t Unknown53; // 0 134 | uint8_t Unknown54; // 0 135 | uint8_t Unknown55; // 0 136 | uint8_t Unknown56; // 0 137 | /* 0xC88 */ uint8_t Unknown57; // 0 138 | uint8_t Unknown58; // 0 139 | uint8_t Unknown59; // 0 140 | uint8_t Unknown60; // 0 141 | uint8_t Unknown61; // 0 142 | uint8_t Unknown62; // 0 143 | uint8_t Unknown63; // 0 144 | uint8_t Unknown64; // default 0xFE 145 | uint8_t Unknown65; 146 | }; 147 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/ActionState.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | struct ActionState 7 | { 8 | uint16_t Msec; // Number of milliseconds the action has been down for 9 | uint8_t Ticks; // Number of ticks the action has been down for 10 | uint8_t Flags; // See the ActionStateFlags enum 11 | float Unknown4; 12 | uint8_t Unknown8; 13 | uint8_t Unknown9; 14 | uint16_t UnknownA; // Padding? 15 | }; 16 | static_assert(sizeof(ActionState) == 0xC, "Invalid ActionState size"); 17 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/ActionStateFlags.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum ActionStateFlags : uint8_t 7 | { 8 | eActionStateFlags_None = 0, 9 | eActionStateFlagsHandled = 1 << 0, // Action has been handled and should be ignored 10 | // TODO: Other flags? 11 | }; 12 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/BindingsPreferences.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "KeyCode.hpp" 3 | #include "MouseButton.hpp" 4 | #include "GameAction.hpp" 5 | 6 | namespace Blam::Input 7 | { 8 | struct BindingsPreferences 9 | { 10 | KeyCode PrimaryKeys[eGameAction_KeyboardMouseCount]; 11 | MouseButton PrimaryMouseButtons[eGameAction_KeyboardMouseCount]; 12 | KeyCode SecondaryKeys[eGameAction_KeyboardMouseCount]; 13 | MouseButton SecondaryMouseButtons[eGameAction_KeyboardMouseCount]; 14 | }; 15 | static_assert(sizeof(BindingsPreferences) == 0x17C, "Invalid BindingsPreferences size"); 16 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/BindingsTable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ControllerButton.hpp" 3 | #include "GameAction.hpp" 4 | #include "KeyCode.hpp" 5 | #include "MouseButton.hpp" 6 | 7 | namespace Blam::Input 8 | { 9 | struct BindingsTable 10 | { 11 | float ControllerSensitivityX; // Default = 120 12 | float ControllerSensitivityY; // Default = 60 13 | ControllerButton ControllerButtons[eGameAction_ControllerCount]; 14 | bool ControllerHoldButtons[eGameAction_ControllerCount]; // true if a button needs to be held down? just a guess 15 | KeyCode PrimaryKeys[eGameAction_KeyboardMouseCount]; 16 | KeyCode SecondaryKeys[eGameAction_KeyboardMouseCount]; 17 | MouseButton PrimaryMouseButtons[eGameAction_KeyboardMouseCount]; 18 | MouseButton SecondaryMouseButtons[eGameAction_KeyboardMouseCount]; 19 | uint32_t Unknown1F8; 20 | uint32_t Unknown1FC; 21 | float Unknown200; // Default = .8 22 | float Unknown204; // Default = 1 23 | }; 24 | static_assert(sizeof(BindingsTable) == 0x208, "Invalid BindingsTable size"); 25 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/ConfigurableAction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Input 4 | { 5 | struct ConfigurableAction 6 | { 7 | const char *Name; // "settings_" followed by the string_id 8 | int DefaultPrimaryKey; // KeyCode, (MouseButton + 1) * 0x100, or -1 9 | int DefaultSecondaryKey; // KeyCode, (MouseButton + 1) * 0x100, or -1 10 | int Action; // GameAction 11 | }; 12 | static_assert(sizeof(ConfigurableAction) == 0x10, "Invalid ConfigurableAction size"); 13 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/ControllerButton.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum ControllerButton : uint8_t 7 | { 8 | eControllerButtonLeftTrigger, 9 | eControllerButtonRightTrigger, 10 | eControllerButtonDpadUp, 11 | eControllerButtonDpadDown, 12 | eControllerButtonDpadLeft, 13 | eControllerButtonDpadRight, 14 | eControllerButtonStart, 15 | eControllerButtonSelect, 16 | eControllerButtonLeftStick, 17 | eControllerButtonRightStick, 18 | eControllerButtonA, 19 | eControllerButtonB, 20 | eControllerButtonX, 21 | eControllerButtonY, 22 | eControllerButtonLeftBumper, 23 | eControllerButtonRightBumper, 24 | 25 | eControllerButton_Count, 26 | eControllerButton_None = 0xFF, // An invalid controller button (for use in unset bindings) 27 | }; 28 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/GameAction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum GameAction : uint8_t 7 | { 8 | // These actions mirror the ControllerButton enum 9 | 10 | eGameActionUiLeftTrigger, 11 | eGameActionUiRightTrigger, 12 | eGameActionUiUp, 13 | eGameActionUiDown, 14 | eGameActionUiLeft, 15 | eGameActionUiRight, 16 | eGameActionUiStart, 17 | eGameActionUiSelect, 18 | eGameActionUiLeftStick, 19 | eGameActionUiRightStick, 20 | eGameActionUiA, 21 | eGameActionUiB, 22 | eGameActionUiX, 23 | eGameActionUiY, 24 | eGameActionUiLeftBumper, 25 | eGameActionUiRightBumper, 26 | 27 | // In-game actions 28 | 29 | eGameActionJump, 30 | eGameActionSwitchGrenades, 31 | eGameActionSwitchWeapons, 32 | eGameActionUnk19, 33 | eGameActionReloadRight, 34 | eGameActionUse, 35 | eGameActionReloadLeft, 36 | eGameActionPickUpLeft, 37 | eGameActionMelee, 38 | eGameActionThrowGrenade, 39 | eGameActionFireRight, 40 | eGameActionFireLeft, 41 | eGameActionMeleeFire, // Fires a weapon with a trigger bound to the melee key 42 | eGameActionCrouch, 43 | eGameActionZoom, 44 | eGameActionUnk31, 45 | eGameActionUnk32, 46 | eGameActionSprint, 47 | eGameActionUnk34, 48 | eGameActionUnk35, 49 | eGameActionUnk36, 50 | eGameActionUnk37, 51 | eGameActionUnk38, 52 | eGameActionGeneralChat, 53 | eGameActionTeamChat, 54 | eGameActionUnk41, 55 | eGameActionUnk42, 56 | eGameActionUnk43, 57 | eGameActionUseConsumable1, 58 | eGameActionUseConsumable2, 59 | eGameActionUseConsumable3, 60 | eGameActionUseConsumable4, 61 | eGameActionVehicleBoost, 62 | eGameActionVehicleDive, 63 | eGameActionVehicleRaise, 64 | eGameActionVehicleAccelerate, 65 | eGameActionVehicleBrake, 66 | eGameActionVehicleFire, 67 | eGameActionVehicleAltFire, 68 | eGameActionVehicleExit, 69 | eGameActionUnk56, 70 | eGameActionUnk57, 71 | eGameActionUnk58, 72 | 73 | eGameAction_ControllerCount = 59, 74 | 75 | // These actions CANNOT be bound to controller buttons or else you 76 | // will overflow the controller bindings array! (Also, it seems 77 | // that mouse bindings will ignore these, even though there's room 78 | // for them.) 79 | 80 | eGameActionMoveForward = 59, 81 | eGameActionMoveBack, 82 | eGameActionMoveLeft, 83 | eGameActionMoveRight, 84 | 85 | eGameAction_KeyboardMouseCount = 63 86 | }; 87 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/InputType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum InputType : uint32_t 7 | { 8 | eInputTypeUi, // ABXY, mouse clicks, etc. 9 | eInputTypeGame, // All in-game actions (including camera) 10 | // Disabled when the pause menu is open 11 | eInputTypeSpecial, // Escape, tab, menu navigation 12 | 13 | eInputType_Count, 14 | }; 15 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/KeyCode.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum KeyCode : uint16_t 7 | { 8 | eKeyCodeEscape, 9 | eKeyCodeF1, 10 | eKeyCodeF2, 11 | eKeyCodeF3, 12 | eKeyCodeF4, 13 | eKeyCodeF5, 14 | eKeyCodeF6, 15 | eKeyCodeF7, 16 | eKeyCodeF8, 17 | eKeyCodeF9, 18 | eKeyCodeF10, 19 | eKeyCodeF11, 20 | eKeyCodeF12, 21 | eKeyCodePrintScreen, 22 | eKeyCodeF14, 23 | eKeyCodeF15, 24 | eKeyCodeTilde, // VK_OEM_3 25 | eKeyCode1, 26 | eKeyCode2, 27 | eKeyCode3, 28 | eKeyCode4, 29 | eKeyCode5, 30 | eKeyCode6, 31 | eKeyCode7, 32 | eKeyCode8, 33 | eKeyCode9, 34 | eKeyCode0, 35 | eKeyCodeMinus, 36 | eKeyCodePlus, 37 | eKeyCodeBack, 38 | eKeyCodeTab, 39 | eKeyCodeQ, 40 | eKeyCodeW, 41 | eKeyCodeE, 42 | eKeyCodeR, 43 | eKeyCodeT, 44 | eKeyCodeY, 45 | eKeyCodeU, 46 | eKeyCodeI, 47 | eKeyCodeO, 48 | eKeyCodeP, 49 | eKeyCodeLBracket, // VK_OEM_4 50 | eKeyCodeRBracket, // VK_OEM_6 51 | eKeyCodePipe, // VK_OEM_5 52 | eKeyCodeCapital, 53 | eKeyCodeA, 54 | eKeyCodeS, 55 | eKeyCodeD, 56 | eKeyCodeF, 57 | eKeyCodeG, 58 | eKeyCodeH, 59 | eKeyCodeJ, 60 | eKeyCodeK, 61 | eKeyCodeL, 62 | eKeyCodeColon, // VK_OEM_1 63 | eKeyCodeQuote, // VK_OEM_7 64 | eKeyCodeEnter, 65 | eKeyCodeLShift, 66 | eKeyCodeZ, 67 | eKeyCodeX, 68 | eKeyCodeC, 69 | eKeyCodeV, 70 | eKeyCodeB, 71 | eKeyCodeN, 72 | eKeyCodeM, 73 | eKeyCodeComma, 74 | eKeyCodePeriod, 75 | eKeyCodeQuestion, // VK_OEM_2 76 | eKeyCodeRShift, 77 | eKeyCodeLControl, 78 | eKeyCodeUnused46, // Left Windows key, but will always fail 79 | eKeyCodeLAlt, 80 | eKeyCodeSpace, 81 | eKeyCodeRAlt, 82 | eKeyCodeUnused4A, // Right Windows key, but will always fail 83 | eKeyCodeApps, 84 | eKeyCodeRcontrol, 85 | eKeyCodeUp, 86 | eKeyCodeDown, 87 | eKeyCodeLeft, 88 | eKeyCodeRight, 89 | eKeyCodeInsert, 90 | eKeyCodeHome, 91 | eKeyCodePageUp, 92 | eKeyCodeDelete, 93 | eKeyCodeEnd, 94 | eKeyCodePageDown, 95 | eKeyCodeNumLock, 96 | eKeyCodeDivide, 97 | eKeyCodeMultiply, 98 | eKeyCodeNumpad0, 99 | eKeyCodeNumpad1, 100 | eKeyCodeNumpad2, 101 | eKeyCodeNumpad3, 102 | eKeyCodeNumpad4, 103 | eKeyCodeNumpad5, 104 | eKeyCodeNumpad6, 105 | eKeyCodeNumpad7, 106 | eKeyCodeNumpad8, 107 | eKeyCodeNumpad9, 108 | eKeyCodeSubtract, 109 | eKeyCodeAdd, 110 | eKeyCodeNumpadEnter, 111 | eKeyCodeDecimal, 112 | eKeyCodeUnused68, 113 | eKeyCodeShift, 114 | eKeyCodeCtrl, 115 | eKeyCodeUnused6B, // Windows key, but will always fail 116 | eKeyCodeAlt, 117 | 118 | eKeyCode_Count, 119 | eKeyCode_None = 0xFF, // An invalid key code (for use in unset bindings) 120 | }; 121 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/KeyEvent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "KeyCode.hpp" 3 | #include "KeyEventModifiers.hpp" 4 | #include "KeyEventType.hpp" 5 | 6 | namespace Blam::Input 7 | { 8 | struct KeyEvent 9 | { 10 | KeyEventModifiers Modifiers; // Bitfield of modifier keys that are down 11 | KeyEventType Type; // Event type 12 | KeyCode Code; // The key code, or -1 if unavailable 13 | char16_t Char; // For eKeyEventTypeChar events, the character that was typed, or -1 if unavailable 14 | bool PreviousState; // If true, the key was down before this event happened 15 | }; 16 | static_assert(sizeof(KeyEvent) == 0x10, "Invalid KeyEvent size"); 17 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/KeyEventModifiers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum KeyEventModifiers : uint8_t 7 | { 8 | eKeyEventModifiersShift = 1 << 0, 9 | eKeyEventModifiersCtrl = 1 << 1, 10 | eKeyEventModifiersalt = 1 << 2, 11 | }; 12 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/KeyEventType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum KeyEventType : uint32_t 7 | { 8 | eKeyEventTypeDown, // A key was pressed. 9 | eKeyEventTypeUp, // A key was released. 10 | eKeyEventTypeChar // A character was typed. 11 | }; 12 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/MouseButton.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum MouseButton : uint8_t 7 | { 8 | eMouseButtonLeft, 9 | eMouseButtonMiddle, 10 | eMouseButtonRight, 11 | eMouseButton4, 12 | eMouseButton5, 13 | 14 | // Not sure what these 3 are...they aren't buttons and can't be bound to anything 15 | eMouseButtonUnk5, 16 | eMouseButtonUnk6, 17 | eMouseButtonUnk7, 18 | 19 | eMouseButtonWheelUp, 20 | eMouseButtonWheelDown, 21 | 22 | eMouseButton_Count, 23 | eMouseButton_None = 0xFF, // An invalid mouse button (for use in unset bindings) 24 | }; 25 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Input/UIButtonCode.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Input 5 | { 6 | enum UiButtonCode : uint32_t 7 | { 8 | eUiButtonCodeA = 0, 9 | eUiButtonCodeB, 10 | eUiButtonCodeX, 11 | eUiButtonCodeY, 12 | eUiButtonCodeRB, 13 | eUiButtonCodeLB, 14 | eUiButtonCodeLT, 15 | eUiButtonCodeRT, 16 | eUiButtonCodeDpadUp, 17 | eUiButtonCodeDpadDown, 18 | eUiButtonCodeDpadLeft, 19 | eUiButtonCodeDpadRight, 20 | eUiButtonCodeStart, 21 | eUiButtonCodeBack, 22 | eUiButtonCodeLS, 23 | eUiButtonCodeRS, 24 | eUiButtonCodeEmulatedInput, 25 | eUiButtonCodeUnk1, 26 | eUiButtonCodeLeft, // analog/arrow left 27 | eUiButtonCodeRight, // analog/arrow right 28 | eUiButtonCodeUp, // analog/arrow up 29 | eUiButtonCodeDown, // analog/arrow down 30 | eUiButtonCodeLSVertical = 0x1A, 31 | eUiButtonCodeRSVertical, 32 | }; 33 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/Angle.cpp: -------------------------------------------------------------------------------- 1 | #include "Angle.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | Angle::Angle() 6 | : Angle(0.0f) 7 | { 8 | } 9 | 10 | Angle::Angle(const float value) 11 | : Value(value) 12 | { 13 | } 14 | 15 | bool Angle::operator==(const Angle &other) const 16 | { 17 | return Value == other.Value; 18 | } 19 | 20 | bool Angle::operator!=(const Angle &other) const 21 | { 22 | return !(*this == other); 23 | } 24 | 25 | Angle::operator float() const 26 | { 27 | return Value; 28 | } 29 | 30 | Angle &Angle::operator+=(const Angle &other) 31 | { 32 | Value += other.Value; 33 | 34 | return *this; 35 | } 36 | 37 | Angle &Angle::operator+=(const float other) 38 | { 39 | Value += other; 40 | 41 | return *this; 42 | } 43 | 44 | Angle Angle::operator+(const Angle &other) const 45 | { 46 | return Angle(Value + other.Value); 47 | } 48 | 49 | Angle Angle::operator+(const float other) const 50 | { 51 | return Angle(Value + other); 52 | } 53 | 54 | Angle operator+(const float a, const Angle &b) 55 | { 56 | return Angle(a + b.Value); 57 | } 58 | 59 | Angle &Angle::operator-=(const Angle &other) 60 | { 61 | Value -= other.Value; 62 | 63 | return *this; 64 | } 65 | 66 | Angle &Angle::operator-=(const float other) 67 | { 68 | Value -= other; 69 | 70 | return *this; 71 | } 72 | 73 | Angle Angle::operator-(const Angle &other) const 74 | { 75 | return Angle(Value - other.Value); 76 | } 77 | 78 | Angle Angle::operator-(const float other) const 79 | { 80 | return Angle(Value - other); 81 | } 82 | 83 | Angle operator-(const float a, const Angle &b) 84 | { 85 | return Angle(a - b.Value); 86 | } 87 | 88 | Angle &Angle::operator*=(const Angle &other) 89 | { 90 | Value *= other.Value; 91 | 92 | return *this; 93 | } 94 | 95 | Angle &Angle::operator*=(const float other) 96 | { 97 | Value *= other; 98 | 99 | return *this; 100 | } 101 | 102 | Angle Angle::operator*(const Angle &other) const 103 | { 104 | return Angle(Value * other.Value); 105 | } 106 | 107 | Angle Angle::operator*(const float other) const 108 | { 109 | return Angle(Value * other); 110 | } 111 | 112 | Angle operator*(const float a, const Angle &b) 113 | { 114 | return Angle(a * b.Value); 115 | } 116 | 117 | Angle &Angle::operator/=(const Angle &other) 118 | { 119 | Value /= other.Value; 120 | 121 | return *this; 122 | } 123 | 124 | Angle &Angle::operator/=(const float other) 125 | { 126 | Value /= other; 127 | 128 | return *this; 129 | } 130 | 131 | Angle Angle::operator/(const Angle &other) const 132 | { 133 | return Angle(Value / other.Value); 134 | } 135 | 136 | Angle Angle::operator/(const float other) const 137 | { 138 | return Angle(Value / other); 139 | } 140 | 141 | Angle operator/(const float a, const Angle &b) 142 | { 143 | return Angle(a / b.Value); 144 | } 145 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/Angle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct Angle 6 | { 7 | float Value; 8 | 9 | Angle(); 10 | Angle(const float value); 11 | 12 | bool operator==(const Angle &other) const; 13 | bool operator!=(const Angle &other) const; 14 | 15 | explicit operator float() const; 16 | 17 | Angle &operator+=(const Angle &other); 18 | Angle &operator+=(const float other); 19 | Angle operator+(const Angle &other) const; 20 | Angle operator+(const float other) const; 21 | friend Angle operator+(const float a, const Angle &b); 22 | 23 | Angle &operator-=(const Angle &other); 24 | Angle &operator-=(const float other); 25 | Angle operator-(const Angle &other) const; 26 | Angle operator-(const float other) const; 27 | friend Angle operator-(const float a, const Angle &b); 28 | 29 | Angle &operator*=(const Angle &other); 30 | Angle &operator*=(const float other); 31 | Angle operator*(const Angle &other) const; 32 | Angle operator*(const float other) const; 33 | friend Angle operator*(const float a, const Angle &b); 34 | 35 | Angle &operator/=(const Angle &other); 36 | Angle &operator/=(const float other); 37 | Angle operator/(const Angle &other) const; 38 | Angle operator/(const float other) const; 39 | friend Angle operator/(const float a, const Angle &b); 40 | }; 41 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/BasePoint2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Math 5 | { 6 | template 7 | struct BasePoint2D 8 | { 9 | T X; 10 | T Y; 11 | 12 | BasePoint2D() 13 | : BasePoint2D(T(), T()) 14 | { 15 | } 16 | 17 | BasePoint2D(const T p_X, const T p_Y) 18 | : X(p_X), Y(p_Y) 19 | { 20 | } 21 | 22 | bool operator==(const BasePoint2D &p_Other) const 23 | { 24 | return (X == p_Other.X) 25 | && (Y == p_Other.Y); 26 | } 27 | 28 | bool operator!=(const BasePoint2D &p_Other) const 29 | { 30 | return !(*this == p_Other); 31 | } 32 | 33 | explicit operator const T *() const 34 | { 35 | return &X; 36 | } 37 | 38 | BasePoint2D &operator+=(const BasePoint2D &p_Other) 39 | { 40 | X += p_Other.X; 41 | Y += p_Other.Y; 42 | 43 | return *this; 44 | } 45 | 46 | BasePoint2D &operator+=(const T p_Other) 47 | { 48 | X += p_Other; 49 | Y += p_Other; 50 | 51 | return *this; 52 | } 53 | 54 | BasePoint2D operator+(const BasePoint2D &p_Other) const 55 | { 56 | return BasePoint2D(X + p_Other.X, Y + p_Other.Y); 57 | } 58 | 59 | BasePoint2D operator+(const T p_Other) const 60 | { 61 | return BasePoint2D(X + p_Other, Y + p_Other); 62 | } 63 | 64 | friend BasePoint2D operator+(const T a, const BasePoint2D &b) 65 | { 66 | return BasePoint2D(a + b.X, a + b.Y); 67 | } 68 | 69 | BasePoint2D &operator-=(const BasePoint2D &p_Other) 70 | { 71 | X -= p_Other.X; 72 | Y -= p_Other.Y; 73 | 74 | return *this; 75 | } 76 | 77 | BasePoint2D &operator-=(const T p_Other) 78 | { 79 | X -= p_Other; 80 | Y -= p_Other; 81 | 82 | return *this; 83 | } 84 | 85 | BasePoint2D operator-(const BasePoint2D &p_Other) const 86 | { 87 | return BasePoint2D(X - p_Other.X, Y - p_Other.Y); 88 | } 89 | 90 | BasePoint2D operator-(const T p_Other) const 91 | { 92 | return BasePoint2D(X - p_Other, Y - p_Other); 93 | } 94 | 95 | friend BasePoint2D operator-(const T a, const BasePoint2D &b) 96 | { 97 | return BasePoint2D(a - b.X, a - b.Y); 98 | } 99 | 100 | BasePoint2D &operator*=(const BasePoint2D &p_Other) 101 | { 102 | X *= p_Other.X; 103 | Y *= p_Other.Y; 104 | 105 | return *this; 106 | } 107 | 108 | BasePoint2D &operator*=(const T p_Other) 109 | { 110 | X *= p_Other; 111 | Y *= p_Other; 112 | 113 | return *this; 114 | } 115 | 116 | BasePoint2D operator*(const BasePoint2D &p_Other) const 117 | { 118 | return BasePoint2D(X * p_Other.X, Y * p_Other.Y); 119 | } 120 | 121 | BasePoint2D operator*(const T p_Other) const 122 | { 123 | return BasePoint2D(X * p_Other, Y * p_Other); 124 | } 125 | 126 | friend BasePoint2D operator*(const T a, const BasePoint2D &b) 127 | { 128 | return BasePoint2D(a * b.X, a * b.Y); 129 | } 130 | 131 | BasePoint2D &operator/=(const BasePoint2D &p_Other) 132 | { 133 | X /= p_Other.X; 134 | Y /= p_Other.Y; 135 | 136 | return *this; 137 | } 138 | 139 | BasePoint2D &operator/=(const T p_Other) 140 | { 141 | X /= p_Other; 142 | Y /= p_Other; 143 | 144 | return *this; 145 | } 146 | 147 | BasePoint2D operator/(const BasePoint2D &p_Other) const 148 | { 149 | return BasePoint2D(X / p_Other.X, Y / p_Other.Y); 150 | } 151 | 152 | BasePoint2D operator/(const T p_Other) const 153 | { 154 | return BasePoint2D(X / p_Other, Y / p_Other); 155 | } 156 | 157 | friend BasePoint2D operator/(const T a, const BasePoint2D &b) 158 | { 159 | return BasePoint2D(a / b.X, a / b.Y); 160 | } 161 | }; 162 | } 163 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/Bounds.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | template 6 | struct Bounds 7 | { 8 | T Lower; 9 | T Upper; 10 | 11 | Bounds(const T &lower, const T &upper) 12 | : Lower(lower), Upper(upper) 13 | { 14 | } 15 | 16 | 17 | Bounds() 18 | : Bounds(T(), T()) 19 | { 20 | } 21 | 22 | bool operator==(const Bounds &p_Other) const 23 | { 24 | return (Lower == other.Lower) 25 | && (Upper == other.Upper); 26 | } 27 | 28 | bool operator!=(const Bounds &p_Other) const 29 | { 30 | return !(*this == p_Other); 31 | } 32 | }; 33 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/ColorARGB.cpp: -------------------------------------------------------------------------------- 1 | #include "ColorARGB.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | ColorARGB::ColorARGB() 6 | : ColorARGB(255, 0, 0, 0) 7 | { 8 | } 9 | 10 | ColorARGB::ColorARGB(const uint8_t alpha, const uint8_t red, const uint8_t green, const uint8_t blue) 11 | : Alpha(alpha), Red(red), Green(green), Blue(blue) 12 | { 13 | } 14 | 15 | bool ColorARGB::operator==(const ColorARGB &other) const 16 | { 17 | return Alpha == other.Alpha 18 | && Red == other.Red 19 | && Green == other.Green 20 | && Blue == other.Blue; 21 | } 22 | 23 | bool ColorARGB::operator!=(const ColorARGB &other) const 24 | { 25 | return !(*this == other); 26 | } 27 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/ColorARGB.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Math 5 | { 6 | struct ColorARGB 7 | { 8 | uint8_t Alpha; 9 | uint8_t Red; 10 | uint8_t Green; 11 | uint8_t Blue; 12 | 13 | ColorARGB(); 14 | ColorARGB(const uint8_t alpha, const uint8_t red, const uint8_t green, const uint8_t blue); 15 | 16 | bool operator==(const ColorARGB &other) const; 17 | bool operator!=(const ColorARGB &other) const; 18 | }; 19 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/ColorRGB.cpp: -------------------------------------------------------------------------------- 1 | #include "ColorRGB.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | ColorRGB::ColorRGB() 6 | : ColorRGB(0, 0, 0) 7 | { 8 | } 9 | 10 | ColorRGB::ColorRGB(const uint8_t red, const uint8_t green, const uint8_t blue) 11 | : Red(red), Green(green), Blue(blue) 12 | { 13 | } 14 | 15 | bool ColorRGB::operator==(const ColorRGB &other) const 16 | { 17 | return Red == other.Red 18 | && Green == other.Green 19 | && Blue == other.Blue; 20 | } 21 | 22 | bool ColorRGB::operator!=(const ColorRGB &other) const 23 | { 24 | return !(*this == other); 25 | } 26 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/ColorRGB.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Math 5 | { 6 | struct ColorRGB 7 | { 8 | uint8_t : 8; 9 | uint8_t Red; 10 | uint8_t Green; 11 | uint8_t Blue; 12 | 13 | ColorRGB(); 14 | ColorRGB(const uint8_t red, const uint8_t green, const uint8_t blue); 15 | 16 | bool operator==(const ColorRGB &other) const; 17 | bool operator!=(const ColorRGB &other) const; 18 | }; 19 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/Point2D.cpp: -------------------------------------------------------------------------------- 1 | #include "Point2D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/Point2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BasePoint2D.hpp" 3 | 4 | namespace Blam::Math 5 | { 6 | typedef BasePoint2D Point2D; 7 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealColorARGB.cpp: -------------------------------------------------------------------------------- 1 | #include "RealColorARGB.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealColorARGB::RealColorARGB() 6 | : RealColorARGB(1.0f, 0.0f, 0.0f, 0.0f) 7 | { 8 | } 9 | 10 | RealColorARGB::RealColorARGB(const float alpha, const float red, const float green, const float blue) 11 | : Alpha(alpha), Red(red), Green(green), Blue(blue) 12 | { 13 | } 14 | 15 | bool RealColorARGB::operator==(const RealColorARGB &other) const 16 | { 17 | return Alpha == other.Alpha 18 | && Red == other.Red 19 | && Green == other.Green 20 | && Blue == other.Blue; 21 | } 22 | 23 | bool RealColorARGB::operator!=(const RealColorARGB &other) const 24 | { 25 | return !(*this == other); 26 | } 27 | 28 | RealColorARGB::operator const float *() const 29 | { 30 | return Α 31 | } 32 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealColorARGB.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct RealColorARGB 6 | { 7 | float Alpha; 8 | float Red; 9 | float Green; 10 | float Blue; 11 | 12 | RealColorARGB(); 13 | RealColorARGB(const float alpha, const float red, const float green, const float blue); 14 | 15 | bool operator==(const RealColorARGB &other) const; 16 | bool operator!=(const RealColorARGB &other) const; 17 | 18 | explicit operator const float *() const; 19 | }; 20 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealColorRGB.cpp: -------------------------------------------------------------------------------- 1 | #include "RealColorRGB.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealColorRGB::RealColorRGB() 6 | : RealColorRGB(0.0f, 0.0f, 0.0f) 7 | { 8 | } 9 | 10 | RealColorRGB::RealColorRGB(const float red, const float green, const float blue) 11 | : Red(red), Green(green), Blue(blue) 12 | { 13 | } 14 | 15 | bool RealColorRGB::operator==(const RealColorRGB &other) const 16 | { 17 | return Red == other.Red 18 | && Green == other.Green 19 | && Blue == other.Blue; 20 | } 21 | 22 | bool RealColorRGB::operator!=(const RealColorRGB &other) const 23 | { 24 | return !(*this == other); 25 | } 26 | 27 | RealColorRGB::operator const float *() const 28 | { 29 | return &Red; 30 | } 31 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealColorRGB.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct RealColorRGB 6 | { 7 | float Red; 8 | float Green; 9 | float Blue; 10 | 11 | RealColorRGB(); 12 | RealColorRGB(const float red, const float green, const float blue); 13 | 14 | bool operator==(const RealColorRGB &other) const; 15 | bool operator!=(const RealColorRGB &other) const; 16 | 17 | explicit operator const float *() const; 18 | }; 19 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealEulerAngles2D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealEulerAngles2D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealEulerAngles2D::RealEulerAngles2D() 6 | : RealEulerAngles2D(Angle(), Angle()) 7 | { 8 | } 9 | 10 | RealEulerAngles2D::RealEulerAngles2D(const Angle &yaw, const Angle &pitch) 11 | : Yaw(yaw), Pitch(pitch) 12 | { 13 | } 14 | 15 | bool RealEulerAngles2D::operator==(const RealEulerAngles2D &other) const 16 | { 17 | return Yaw == other.Yaw 18 | && Pitch == other.Pitch; 19 | } 20 | 21 | bool RealEulerAngles2D::operator!=(const RealEulerAngles2D &other) const 22 | { 23 | return !(*this == other); 24 | } 25 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealEulerAngles2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Angle.hpp" 3 | 4 | namespace Blam::Math 5 | { 6 | struct RealEulerAngles2D 7 | { 8 | Angle Yaw; 9 | Angle Pitch; 10 | 11 | RealEulerAngles2D(); 12 | RealEulerAngles2D(const Angle &yaw, const Angle &pitch); 13 | 14 | bool operator==(const RealEulerAngles2D &other) const; 15 | bool operator!=(const RealEulerAngles2D &other) const; 16 | }; 17 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealEulerAngles3D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealEulerAngles3D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealEulerAngles3D::RealEulerAngles3D() 6 | : RealEulerAngles3D(Angle(), Angle(), Angle()) 7 | { 8 | } 9 | 10 | RealEulerAngles3D::RealEulerAngles3D(const Angle &yaw, const Angle &pitch, const Angle &roll) 11 | : Yaw(yaw), Pitch(pitch), Roll(roll) 12 | { 13 | } 14 | 15 | bool RealEulerAngles3D::operator==(const RealEulerAngles3D &other) const 16 | { 17 | return Yaw == other.Yaw 18 | && Pitch == other.Pitch 19 | && Roll == other.Roll; 20 | } 21 | 22 | bool RealEulerAngles3D::operator!=(const RealEulerAngles3D &other) const 23 | { 24 | return !(*this == other); 25 | } 26 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealEulerAngles3D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Angle.hpp" 3 | 4 | namespace Blam::Math 5 | { 6 | struct RealEulerAngles3D 7 | { 8 | Angle Yaw; 9 | Angle Pitch; 10 | Angle Roll; 11 | 12 | RealEulerAngles3D(); 13 | RealEulerAngles3D(const Angle &yaw, const Angle &pitch, const Angle &roll); 14 | 15 | bool operator==(const RealEulerAngles3D &other) const; 16 | bool operator!=(const RealEulerAngles3D &other) const; 17 | }; 18 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealMatrix3x3.cpp: -------------------------------------------------------------------------------- 1 | #include "RealMatrix3x3.hpp" 2 | 3 | namespace Blam 4 | { 5 | namespace Math 6 | { 7 | RealMatrix3x3::RealMatrix3x3() 8 | : RealMatrix3x3(RealVector3D(), RealVector3D(), RealVector3D()) 9 | { 10 | } 11 | 12 | RealMatrix3x3::RealMatrix3x3(const RealVector3D &forward, const RealVector3D &left, const RealVector3D &up) 13 | : Forward(forward), Left(left), Up(up) 14 | { 15 | } 16 | 17 | bool RealMatrix3x3::operator==(const RealMatrix3x3 &other) const 18 | { 19 | return Forward == other.Forward 20 | && Left == other.Left 21 | && Up == other.Up; 22 | } 23 | 24 | bool RealMatrix3x3::operator!=(const RealMatrix3x3 &other) const 25 | { 26 | return !(*this == other); 27 | } 28 | 29 | RealMatrix3x3::operator const float *() const 30 | { 31 | return Forward.operator const float *(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealMatrix3x3.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "RealVector3D.hpp" 3 | 4 | namespace Blam::Math 5 | { 6 | struct RealMatrix3x3 7 | { 8 | RealVector3D Forward; 9 | RealVector3D Left; 10 | RealVector3D Up; 11 | 12 | RealMatrix3x3(); 13 | RealMatrix3x3(const RealVector3D &forward, const RealVector3D &left, const RealVector3D &up); 14 | 15 | bool operator==(const RealMatrix3x3 &other) const; 16 | bool operator!=(const RealMatrix3x3 &other) const; 17 | 18 | explicit operator const float *() const; 19 | }; 20 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealMatrix4x3.cpp: -------------------------------------------------------------------------------- 1 | #include "RealMatrix4x3.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealMatrix4x3::RealMatrix4x3() 6 | : RealMatrix4x3(0.0f, RealVector3D(), RealVector3D(), RealVector3D(), RealPoint3D()) 7 | { 8 | } 9 | 10 | RealMatrix4x3::RealMatrix4x3(const float scale, const RealVector3D &forward, const RealVector3D &left, const RealVector3D &up, const RealPoint3D &position) 11 | : Scale(scale), Forward(forward), Left(left), Up(up), Position(position) 12 | { 13 | } 14 | 15 | bool RealMatrix4x3::operator==(const RealMatrix4x3 &other) const 16 | { 17 | return Scale == other.Scale 18 | && Forward == other.Forward 19 | && Left == other.Left 20 | && Up == other.Up 21 | && Position == other.Position; 22 | } 23 | 24 | bool RealMatrix4x3::operator!=(const RealMatrix4x3 &other) const 25 | { 26 | return !(*this == other); 27 | } 28 | 29 | RealMatrix4x3::operator const float *() const 30 | { 31 | return &Scale; 32 | } 33 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealMatrix4x3.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "RealPoint3D.hpp" 3 | #include "RealVector3D.hpp" 4 | 5 | namespace Blam::Math 6 | { 7 | struct RealMatrix4x3 8 | { 9 | float Scale; 10 | RealVector3D Forward; 11 | RealVector3D Left; 12 | RealVector3D Up; 13 | RealPoint3D Position; 14 | 15 | RealMatrix4x3(); 16 | RealMatrix4x3(const float scale, const RealVector3D &forward, const RealVector3D &left, const RealVector3D &up, const RealPoint3D &position); 17 | 18 | bool operator==(const RealMatrix4x3 &other) const; 19 | bool operator!=(const RealMatrix4x3 &other) const; 20 | 21 | explicit operator const float *() const; 22 | }; 23 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealOrientation3D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealOrientation3D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealOrientation3D::RealOrientation3D() 6 | : RealOrientation3D(RealQuaternion(), RealPoint3D(), 0.0f) 7 | { 8 | } 9 | 10 | RealOrientation3D::RealOrientation3D(const RealQuaternion &rotation, const RealPoint3D &translation, const float scale) 11 | : Rotation(rotation), Translation(translation), Scale(scale) 12 | { 13 | } 14 | 15 | bool RealOrientation3D::operator==(const RealOrientation3D &other) const 16 | { 17 | return Rotation == other.Rotation 18 | && Translation == other.Translation 19 | && Scale == other.Scale; 20 | } 21 | 22 | bool RealOrientation3D::operator!=(const RealOrientation3D &other) const 23 | { 24 | return !(*this == other); 25 | } 26 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealOrientation3D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "RealPoint3D.hpp" 3 | #include "RealQuaternion.hpp" 4 | 5 | namespace Blam::Math 6 | { 7 | struct RealOrientation3D 8 | { 9 | RealQuaternion Rotation; 10 | RealPoint3D Translation; 11 | float Scale; 12 | 13 | RealOrientation3D(); 14 | RealOrientation3D(const RealQuaternion &rotation, const RealPoint3D &translation, const float scale); 15 | 16 | bool operator==(const RealOrientation3D &other) const; 17 | bool operator!=(const RealOrientation3D &other) const; 18 | }; 19 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealPlane2D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealPlane2D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealPlane2D::RealPlane2D() 6 | : RealPlane2D(RealVector2D(), 0.0f) 7 | { 8 | } 9 | 10 | RealPlane2D::RealPlane2D(const RealVector2D &normal, const float distance) 11 | : Normal(normal), Distance(distance) 12 | { 13 | } 14 | 15 | RealPlane2D::RealPlane2D(const float i, const float j, const float d) 16 | : Normal(RealVector2D(i, j)), Distance(d) 17 | { 18 | } 19 | 20 | bool RealPlane2D::operator==(const RealPlane2D &other) const 21 | { 22 | return Normal == other.Normal 23 | && Distance == other.Distance; 24 | } 25 | 26 | bool RealPlane2D::operator!=(const RealPlane2D &other) const 27 | { 28 | return !(*this == other); 29 | } 30 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealPlane2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "RealVector2D.hpp" 3 | 4 | namespace Blam::Math 5 | { 6 | struct RealPlane2D 7 | { 8 | RealVector2D Normal; 9 | float Distance; 10 | 11 | RealPlane2D(); 12 | RealPlane2D(const RealVector2D &normal, const float distance); 13 | RealPlane2D(const float i, const float j, const float d); 14 | 15 | bool operator==(const RealPlane2D &other) const; 16 | bool operator!=(const RealPlane2D &other) const; 17 | }; 18 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealPlane3D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealPlane3D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealPlane3D::RealPlane3D() 6 | : RealPlane3D(RealVector3D(), 0.0f) 7 | { 8 | } 9 | 10 | RealPlane3D::RealPlane3D(const RealVector3D &normal, const float distance) 11 | : Normal(normal), Distance(distance) 12 | { 13 | } 14 | 15 | RealPlane3D::RealPlane3D(const float i, const float j, const float k, const float d) 16 | : Normal(RealVector3D(i, j, k)), Distance(d) 17 | { 18 | } 19 | 20 | bool RealPlane3D::operator==(const RealPlane3D &other) const 21 | { 22 | return Normal == other.Normal 23 | && Distance == other.Distance; 24 | } 25 | 26 | bool RealPlane3D::operator!=(const RealPlane3D &other) const 27 | { 28 | return !(*this == other); 29 | } 30 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealPlane3D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "RealVector3D.hpp" 3 | 4 | namespace Blam::Math 5 | { 6 | struct RealPlane3D 7 | { 8 | RealVector3D Normal; 9 | float Distance; 10 | 11 | RealPlane3D(); 12 | RealPlane3D(const RealVector3D &normal, const float distance); 13 | RealPlane3D(const float i, const float j, const float k, const float d); 14 | 15 | bool operator==(const RealPlane3D &other) const; 16 | bool operator!=(const RealPlane3D &other) const; 17 | }; 18 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealPoint2D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealPoint2D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealPoint2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "BasePoint2D.hpp" 3 | 4 | namespace Blam::Math 5 | { 6 | typedef BasePoint2D RealPoint2D; 7 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealPoint3D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealPoint3D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealPoint3D::RealPoint3D() 6 | : RealPoint3D(0.0f, 0.0f, 0.0f) 7 | { 8 | } 9 | 10 | RealPoint3D::RealPoint3D(const float x, const float y, const float z) 11 | : X(x), Y(y), Z(z) 12 | { 13 | } 14 | 15 | bool RealPoint3D::operator==(const RealPoint3D &other) const 16 | { 17 | return X == other.X 18 | && Y == other.Y 19 | && Z == other.Z; 20 | } 21 | 22 | bool RealPoint3D::operator!=(const RealPoint3D &other) const 23 | { 24 | return !(*this == other); 25 | } 26 | 27 | RealPoint3D::operator const float *() const 28 | { 29 | return &X; 30 | } 31 | 32 | RealPoint3D &RealPoint3D::operator+=(const RealPoint3D &other) 33 | { 34 | X += other.X; 35 | Y += other.Y; 36 | Z += other.Z; 37 | 38 | return *this; 39 | } 40 | 41 | RealPoint3D &RealPoint3D::operator+=(const float other) 42 | { 43 | X += other; 44 | Y += other; 45 | Z += other; 46 | 47 | return *this; 48 | } 49 | 50 | RealPoint3D RealPoint3D::operator+(const RealPoint3D &other) const 51 | { 52 | return RealPoint3D(X + other.X, Y + other.Y, Z + other.Z); 53 | } 54 | 55 | RealPoint3D RealPoint3D::operator+(const float other) const 56 | { 57 | return RealPoint3D(X + other, Y + other, Z + other); 58 | } 59 | 60 | RealPoint3D operator+(const float a, const RealPoint3D &b) 61 | { 62 | return RealPoint3D(a + b.X, a + b.Y, a + b.Z); 63 | } 64 | 65 | RealPoint3D &RealPoint3D::operator-=(const RealPoint3D &other) 66 | { 67 | X -= other.X; 68 | Y -= other.Y; 69 | Z -= other.Z; 70 | 71 | return *this; 72 | } 73 | 74 | RealPoint3D &RealPoint3D::operator-=(const float other) 75 | { 76 | X -= other; 77 | Y -= other; 78 | Z -= other; 79 | 80 | return *this; 81 | } 82 | 83 | RealPoint3D RealPoint3D::operator-(const RealPoint3D &other) const 84 | { 85 | return RealPoint3D(X - other.X, Y - other.Y, Z - other.Z); 86 | } 87 | 88 | RealPoint3D RealPoint3D::operator-(const float other) const 89 | { 90 | return RealPoint3D(X - other, Y - other, Z - other); 91 | } 92 | 93 | RealPoint3D operator-(const float a, const RealPoint3D &b) 94 | { 95 | return RealPoint3D(a - b.X, a - b.Y, a - b.Z); 96 | } 97 | 98 | RealPoint3D &RealPoint3D::operator*=(const RealPoint3D &other) 99 | { 100 | X *= other.X; 101 | Y *= other.Y; 102 | Z *= other.Z; 103 | 104 | return *this; 105 | } 106 | 107 | RealPoint3D &RealPoint3D::operator*=(const float other) 108 | { 109 | X *= other; 110 | Y *= other; 111 | Z *= other; 112 | 113 | return *this; 114 | } 115 | 116 | RealPoint3D RealPoint3D::operator*(const RealPoint3D &other) const 117 | { 118 | return RealPoint3D(X * other.X, Y * other.Y, Z * other.Z); 119 | } 120 | 121 | RealPoint3D RealPoint3D::operator*(const float other) const 122 | { 123 | return RealPoint3D(X * other, Y * other, Z * other); 124 | } 125 | 126 | RealPoint3D operator*(const float a, const RealPoint3D &b) 127 | { 128 | return RealPoint3D(a * b.X, a * b.Y, a * b.Z); 129 | } 130 | 131 | RealPoint3D &RealPoint3D::operator/=(const RealPoint3D &other) 132 | { 133 | X /= other.X; 134 | Y /= other.Y; 135 | Z /= other.Z; 136 | 137 | return *this; 138 | } 139 | 140 | RealPoint3D &RealPoint3D::operator/=(const float other) 141 | { 142 | X /= other; 143 | Y /= other; 144 | Z /= other; 145 | 146 | return *this; 147 | } 148 | 149 | RealPoint3D RealPoint3D::operator/(const RealPoint3D &other) const 150 | { 151 | return RealPoint3D(X / other.X, Y / other.Y, Z / other.Z); 152 | } 153 | 154 | RealPoint3D RealPoint3D::operator/(const float other) const 155 | { 156 | return RealPoint3D(X / other, Y / other, Z / other); 157 | } 158 | 159 | RealPoint3D operator/(const float a, const RealPoint3D &b) 160 | { 161 | return RealPoint3D(a / b.X, a / b.Y, a / b.Z); 162 | } 163 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealPoint3D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct RealPoint3D 6 | { 7 | float X; 8 | float Y; 9 | float Z; 10 | 11 | RealPoint3D(); 12 | RealPoint3D(const float x, const float y, const float z); 13 | 14 | bool operator==(const RealPoint3D &other) const; 15 | bool operator!=(const RealPoint3D &other) const; 16 | 17 | explicit operator const float *() const; 18 | 19 | RealPoint3D &operator+=(const RealPoint3D &other); 20 | RealPoint3D &operator+=(const float other); 21 | RealPoint3D operator+(const RealPoint3D &other) const; 22 | RealPoint3D operator+(const float other) const; 23 | friend RealPoint3D operator+(const float a, const RealPoint3D &b); 24 | 25 | RealPoint3D &operator-=(const RealPoint3D &other); 26 | RealPoint3D &operator-=(const float other); 27 | RealPoint3D operator-(const RealPoint3D &other) const; 28 | RealPoint3D operator-(const float other) const; 29 | friend RealPoint3D operator-(const float a, const RealPoint3D &b); 30 | 31 | RealPoint3D &operator*=(const RealPoint3D &other); 32 | RealPoint3D &operator*=(const float other); 33 | RealPoint3D operator*(const RealPoint3D &other) const; 34 | RealPoint3D operator*(const float other) const; 35 | friend RealPoint3D operator*(const float a, const RealPoint3D &b); 36 | 37 | RealPoint3D &operator/=(const RealPoint3D &other); 38 | RealPoint3D &operator/=(const float other); 39 | RealPoint3D operator/(const RealPoint3D &other) const; 40 | RealPoint3D operator/(const float other) const; 41 | friend RealPoint3D operator/(const float a, const RealPoint3D &b); 42 | }; 43 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealQuaternion.cpp: -------------------------------------------------------------------------------- 1 | #include "RealQuaternion.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealQuaternion::RealQuaternion() 6 | : RealQuaternion(0.0f, 0.0f, 0.0f, 1.0f) 7 | { 8 | } 9 | 10 | RealQuaternion::RealQuaternion(const float i, const float j, const float k, const float w) 11 | : I(i), J(j), K(k), W(w) 12 | { 13 | } 14 | 15 | bool RealQuaternion::operator==(const RealQuaternion &other) const 16 | { 17 | return I == other.I 18 | && J == other.J 19 | && K == other.K 20 | && W == other.W; 21 | } 22 | 23 | bool RealQuaternion::operator!=(const RealQuaternion &other) const 24 | { 25 | return !(*this == other); 26 | } 27 | 28 | RealQuaternion::operator const float *() const 29 | { 30 | return &I; 31 | } 32 | 33 | RealQuaternion &RealQuaternion::operator+=(const RealQuaternion &other) 34 | { 35 | I += other.I; 36 | J += other.J; 37 | K += other.K; 38 | W += other.W; 39 | 40 | return *this; 41 | } 42 | 43 | RealQuaternion &RealQuaternion::operator+=(const float other) 44 | { 45 | I += other; 46 | J += other; 47 | K += other; 48 | W += other; 49 | 50 | return *this; 51 | } 52 | 53 | RealQuaternion RealQuaternion::operator+(const RealQuaternion &other) const 54 | { 55 | return RealQuaternion(I + other.I, J + other.J, K + other.K, W + other.W); 56 | } 57 | 58 | RealQuaternion RealQuaternion::operator+(const float other) const 59 | { 60 | return RealQuaternion(I + other, J + other, K + other, W + other); 61 | } 62 | 63 | RealQuaternion operator+(const float a, const RealQuaternion &b) 64 | { 65 | return RealQuaternion(a + b.I, a + b.J, a + b.K, a + b.W); 66 | } 67 | 68 | RealQuaternion &RealQuaternion::operator-=(const RealQuaternion &other) 69 | { 70 | I -= other.I; 71 | J -= other.J; 72 | K -= other.K; 73 | W -= other.W; 74 | 75 | return *this; 76 | } 77 | 78 | RealQuaternion &RealQuaternion::operator-=(const float other) 79 | { 80 | I -= other; 81 | J -= other; 82 | K -= other; 83 | W -= other; 84 | 85 | return *this; 86 | } 87 | 88 | RealQuaternion RealQuaternion::operator-(const RealQuaternion &other) const 89 | { 90 | return RealQuaternion(I - other.I, J - other.J, K - other.K, W - other.W); 91 | } 92 | 93 | RealQuaternion RealQuaternion::operator-(const float other) const 94 | { 95 | return RealQuaternion(I - other, J - other, K - other, W - other); 96 | } 97 | 98 | RealQuaternion operator-(const float a, const RealQuaternion &b) 99 | { 100 | return RealQuaternion(a - b.I, a - b.J, a - b.K, a - b.W); 101 | } 102 | 103 | RealQuaternion &RealQuaternion::operator*=(const RealQuaternion &other) 104 | { 105 | I *= other.I; 106 | J *= other.J; 107 | K *= other.K; 108 | W *= other.W; 109 | 110 | return *this; 111 | } 112 | 113 | RealQuaternion &RealQuaternion::operator*=(const float other) 114 | { 115 | I *= other; 116 | J *= other; 117 | K *= other; 118 | W *= other; 119 | 120 | return *this; 121 | } 122 | 123 | RealQuaternion RealQuaternion::operator*(const RealQuaternion &other) const 124 | { 125 | return RealQuaternion(I * other.I, J * other.J, K * other.K, W * other.W); 126 | } 127 | 128 | RealQuaternion RealQuaternion::operator*(const float other) const 129 | { 130 | return RealQuaternion(I * other, J * other, K * other, W * other); 131 | } 132 | 133 | RealQuaternion operator*(const float a, const RealQuaternion &b) 134 | { 135 | return RealQuaternion(a * b.I, a * b.J, a * b.K, a * b.W); 136 | } 137 | 138 | RealQuaternion &RealQuaternion::operator/=(const RealQuaternion &other) 139 | { 140 | I /= other.I; 141 | J /= other.J; 142 | K /= other.K; 143 | W /= other.W; 144 | 145 | return *this; 146 | } 147 | 148 | RealQuaternion &RealQuaternion::operator/=(const float other) 149 | { 150 | I /= other; 151 | J /= other; 152 | K /= other; 153 | W /= other; 154 | 155 | return *this; 156 | } 157 | 158 | RealQuaternion RealQuaternion::operator/(const RealQuaternion &other) const 159 | { 160 | return RealQuaternion(I / other.I, J / other.J, K / other.K, W / other.W); 161 | } 162 | 163 | RealQuaternion RealQuaternion::operator/(const float other) const 164 | { 165 | return RealQuaternion(I / other, J / other, K / other, W / other); 166 | } 167 | 168 | RealQuaternion operator/(const float a, const RealQuaternion &b) 169 | { 170 | return RealQuaternion(a / b.I, a / b.J, a / b.K, a / b.W); 171 | } 172 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealQuaternion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct RealQuaternion 6 | { 7 | float I; 8 | float J; 9 | float K; 10 | float W; 11 | 12 | RealQuaternion(); 13 | RealQuaternion(const float i, const float j, const float k, const float w); 14 | 15 | bool operator==(const RealQuaternion &other) const; 16 | bool operator!=(const RealQuaternion &other) const; 17 | 18 | explicit operator const float *() const; 19 | 20 | RealQuaternion &operator+=(const RealQuaternion &other); 21 | RealQuaternion &operator+=(const float other); 22 | RealQuaternion operator+(const RealQuaternion &other) const; 23 | RealQuaternion operator+(const float other) const; 24 | friend RealQuaternion operator+(const float a, const RealQuaternion &b); 25 | 26 | RealQuaternion &operator-=(const RealQuaternion &other); 27 | RealQuaternion &operator-=(const float other); 28 | RealQuaternion operator-(const RealQuaternion &other) const; 29 | RealQuaternion operator-(const float other) const; 30 | friend RealQuaternion operator-(const float a, const RealQuaternion &b); 31 | 32 | RealQuaternion &operator*=(const RealQuaternion &other); 33 | RealQuaternion &operator*=(const float other); 34 | RealQuaternion operator*(const RealQuaternion &other) const; 35 | RealQuaternion operator*(const float other) const; 36 | friend RealQuaternion operator*(const float a, const RealQuaternion &b); 37 | 38 | RealQuaternion &operator/=(const RealQuaternion &other); 39 | RealQuaternion &operator/=(const float other); 40 | RealQuaternion operator/(const RealQuaternion &other) const; 41 | RealQuaternion operator/(const float other) const; 42 | friend RealQuaternion operator/(const float a, const RealQuaternion &b); 43 | }; 44 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealRectangle2D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealRectangle2D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealRectangle2D::RealRectangle2D() 6 | : RealRectangle2D(0.0f, 0.0f, 0.0f, 0.0f) 7 | { 8 | } 9 | 10 | RealRectangle2D::RealRectangle2D(const float top, const float bottom, const float left, const float right) 11 | : Top(top), Bottom(bottom), Left(left), Right(right) 12 | { 13 | } 14 | 15 | bool RealRectangle2D::operator==(const RealRectangle2D &other) const 16 | { 17 | return Top == other.Top 18 | && Bottom == other.Bottom 19 | && Left == other.Left 20 | && Right == other.Right; 21 | } 22 | 23 | bool RealRectangle2D::operator!=(const RealRectangle2D &other) const 24 | { 25 | return !(*this == other); 26 | } 27 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealRectangle2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct RealRectangle2D 6 | { 7 | float Top; 8 | float Bottom; 9 | float Left; 10 | float Right; 11 | 12 | RealRectangle2D(); 13 | RealRectangle2D(const float top, const float bottom, const float left, const float right); 14 | 15 | bool operator==(const RealRectangle2D &other) const; 16 | bool operator!=(const RealRectangle2D &other) const; 17 | }; 18 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealRectangle3D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealRectangle3D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealRectangle3D::RealRectangle3D() 6 | : RealRectangle3D(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f) 7 | { 8 | } 9 | 10 | RealRectangle3D::RealRectangle3D(const float top, const float bottom, const float left, const float right, const float front, const float back) 11 | : Top(top), Bottom(bottom), Left(left), Right(right), Front(front), Back(back) 12 | { 13 | } 14 | 15 | bool RealRectangle3D::operator==(const RealRectangle3D &other) const 16 | { 17 | return Top == other.Top 18 | && Bottom == other.Bottom 19 | && Left == other.Left 20 | && Right == other.Right 21 | && Front == other.Front 22 | && Back == other.Back; 23 | } 24 | 25 | bool RealRectangle3D::operator!=(const RealRectangle3D &other) const 26 | { 27 | return !(*this == other); 28 | } 29 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealRectangle3D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct RealRectangle3D 6 | { 7 | float Top; 8 | float Bottom; 9 | float Left; 10 | float Right; 11 | float Front; 12 | float Back; 13 | 14 | RealRectangle3D(); 15 | RealRectangle3D(const float top, const float bottom, const float left, const float right, const float front, const float back); 16 | 17 | bool operator==(const RealRectangle3D &other) const; 18 | bool operator!=(const RealRectangle3D &other) const; 19 | }; 20 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealVector2D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealVector2D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealVector2D::RealVector2D() 6 | : RealVector2D(0, 0) 7 | { 8 | } 9 | 10 | RealVector2D::RealVector2D(const float i, const float j) 11 | : I(i), J(j) 12 | { 13 | } 14 | 15 | bool RealVector2D::operator==(const RealVector2D &other) const 16 | { 17 | return I == other.I 18 | && J == other.J; 19 | } 20 | 21 | bool RealVector2D::operator!=(const RealVector2D &other) const 22 | { 23 | return !(*this == other); 24 | } 25 | 26 | RealVector2D::operator const float *() const 27 | { 28 | return &I; 29 | } 30 | 31 | RealVector2D &RealVector2D::operator+=(const RealVector2D &other) 32 | { 33 | I += other.I; 34 | J += other.J; 35 | 36 | return *this; 37 | } 38 | 39 | RealVector2D &RealVector2D::operator+=(const float other) 40 | { 41 | I += other; 42 | J += other; 43 | 44 | return *this; 45 | } 46 | 47 | RealVector2D RealVector2D::operator+(const RealVector2D &other) const 48 | { 49 | return RealVector2D(I + other.I, J + other.J); 50 | } 51 | 52 | RealVector2D RealVector2D::operator+(const float other) const 53 | { 54 | return RealVector2D(I + other, J + other); 55 | } 56 | 57 | RealVector2D operator+(const float a, const RealVector2D &b) 58 | { 59 | return RealVector2D(a + b.I, a + b.J); 60 | } 61 | 62 | RealVector2D &RealVector2D::operator-=(const RealVector2D &other) 63 | { 64 | I -= other.I; 65 | J -= other.J; 66 | 67 | return *this; 68 | } 69 | 70 | RealVector2D &RealVector2D::operator-=(const float other) 71 | { 72 | I -= other; 73 | J -= other; 74 | 75 | return *this; 76 | } 77 | 78 | RealVector2D RealVector2D::operator-(const RealVector2D &other) const 79 | { 80 | return RealVector2D(I - other.I, J - other.J); 81 | } 82 | 83 | RealVector2D RealVector2D::operator-(const float other) const 84 | { 85 | return RealVector2D(I - other, J - other); 86 | } 87 | 88 | RealVector2D operator-(const float a, const RealVector2D &b) 89 | { 90 | return RealVector2D(a - b.I, a - b.J); 91 | } 92 | 93 | RealVector2D &RealVector2D::operator*=(const RealVector2D &other) 94 | { 95 | I *= other.I; 96 | J *= other.J; 97 | 98 | return *this; 99 | } 100 | 101 | RealVector2D &RealVector2D::operator*=(const float other) 102 | { 103 | I *= other; 104 | J *= other; 105 | 106 | return *this; 107 | } 108 | 109 | RealVector2D RealVector2D::operator*(const RealVector2D &other) const 110 | { 111 | return RealVector2D(I * other.I, J * other.J); 112 | } 113 | 114 | RealVector2D RealVector2D::operator*(const float other) const 115 | { 116 | return RealVector2D(I * other, J * other); 117 | } 118 | 119 | RealVector2D operator*(const float a, const RealVector2D &b) 120 | { 121 | return RealVector2D(a * b.I, a * b.J); 122 | } 123 | 124 | RealVector2D &RealVector2D::operator/=(const RealVector2D &other) 125 | { 126 | I /= other.I; 127 | J /= other.J; 128 | 129 | return *this; 130 | } 131 | 132 | RealVector2D &RealVector2D::operator/=(const float other) 133 | { 134 | I /= other; 135 | J /= other; 136 | 137 | return *this; 138 | } 139 | 140 | RealVector2D RealVector2D::operator/(const RealVector2D &other) const 141 | { 142 | return RealVector2D(I / other.I, J / other.J); 143 | } 144 | 145 | RealVector2D RealVector2D::operator/(const float other) const 146 | { 147 | return RealVector2D(I / other, J / other); 148 | } 149 | 150 | RealVector2D operator/(const float a, const RealVector2D &b) 151 | { 152 | return RealVector2D(a / b.I, a / b.J); 153 | } 154 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealVector2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct RealVector2D 6 | { 7 | float I; 8 | float J; 9 | 10 | RealVector2D(); 11 | RealVector2D(const float i, const float j); 12 | 13 | bool operator==(const RealVector2D &other) const; 14 | bool operator!=(const RealVector2D &other) const; 15 | 16 | explicit operator const float *() const; 17 | 18 | RealVector2D &operator+=(const RealVector2D &other); 19 | RealVector2D &operator+=(const float other); 20 | RealVector2D operator+(const RealVector2D &other) const; 21 | RealVector2D operator+(const float other) const; 22 | friend RealVector2D operator+(const float a, const RealVector2D &b); 23 | 24 | RealVector2D &operator-=(const RealVector2D &other); 25 | RealVector2D &operator-=(const float other); 26 | RealVector2D operator-(const RealVector2D &other) const; 27 | RealVector2D operator-(const float other) const; 28 | friend RealVector2D operator-(const float a, const RealVector2D &b); 29 | 30 | RealVector2D &operator*=(const RealVector2D &other); 31 | RealVector2D &operator*=(const float other); 32 | RealVector2D operator*(const RealVector2D &other) const; 33 | RealVector2D operator*(const float other) const; 34 | friend RealVector2D operator*(const float a, const RealVector2D &b); 35 | 36 | RealVector2D &operator/=(const RealVector2D &other); 37 | RealVector2D &operator/=(const float other); 38 | RealVector2D operator/(const RealVector2D &other) const; 39 | RealVector2D operator/(const float other) const; 40 | friend RealVector2D operator/(const float a, const RealVector2D &b); 41 | }; 42 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealVector3D.cpp: -------------------------------------------------------------------------------- 1 | #include "RealVector3D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | RealVector3D::RealVector3D() 6 | : RealVector3D(0.0f, 0.0f, 0.0f) 7 | { 8 | } 9 | 10 | RealVector3D::RealVector3D(const float i, const float j, const float k) 11 | : I(i), J(j), K(k) 12 | { 13 | } 14 | 15 | bool RealVector3D::operator==(const RealVector3D &other) const 16 | { 17 | return I == other.I 18 | && J == other.J 19 | && K == other.K; 20 | } 21 | 22 | bool RealVector3D::operator!=(const RealVector3D &other) const 23 | { 24 | return !(*this == other); 25 | } 26 | 27 | RealVector3D::operator const float *() const 28 | { 29 | return &I; 30 | } 31 | 32 | RealVector3D &RealVector3D::operator+=(const RealVector3D &other) 33 | { 34 | I += other.I; 35 | J += other.J; 36 | K += other.K; 37 | 38 | return *this; 39 | } 40 | 41 | RealVector3D &RealVector3D::operator+=(const float other) 42 | { 43 | I += other; 44 | J += other; 45 | K += other; 46 | 47 | return *this; 48 | } 49 | 50 | RealVector3D RealVector3D::operator+(const RealVector3D &other) const 51 | { 52 | return RealVector3D(I + other.I, J + other.J, K + other.K); 53 | } 54 | 55 | RealVector3D RealVector3D::operator+(const float other) const 56 | { 57 | return RealVector3D(I + other, J + other, K + other); 58 | } 59 | 60 | RealVector3D operator+(const float a, const RealVector3D &b) 61 | { 62 | return RealVector3D(a + b.I, a + b.J, a + b.K); 63 | } 64 | 65 | RealVector3D &RealVector3D::operator-=(const RealVector3D &other) 66 | { 67 | I -= other.I; 68 | J -= other.J; 69 | K -= other.K; 70 | 71 | return *this; 72 | } 73 | 74 | RealVector3D &RealVector3D::operator-=(const float other) 75 | { 76 | I -= other; 77 | J -= other; 78 | K -= other; 79 | 80 | return *this; 81 | } 82 | 83 | RealVector3D RealVector3D::operator-(const RealVector3D &other) const 84 | { 85 | return RealVector3D(I - other.I, J - other.J, K - other.K); 86 | } 87 | 88 | RealVector3D RealVector3D::operator-(const float other) const 89 | { 90 | return RealVector3D(I - other, J - other, K - other); 91 | } 92 | 93 | RealVector3D operator-(const float a, const RealVector3D &b) 94 | { 95 | return RealVector3D(a - b.I, a - b.J, a - b.K); 96 | } 97 | 98 | RealVector3D &RealVector3D::operator*=(const RealVector3D &other) 99 | { 100 | I *= other.I; 101 | J *= other.J; 102 | K *= other.K; 103 | 104 | return *this; 105 | } 106 | 107 | RealVector3D &RealVector3D::operator*=(const float other) 108 | { 109 | I *= other; 110 | J *= other; 111 | K *= other; 112 | 113 | return *this; 114 | } 115 | 116 | RealVector3D RealVector3D::operator*(const RealVector3D &other) const 117 | { 118 | return RealVector3D(I * other.I, J * other.J, K * other.K); 119 | } 120 | 121 | RealVector3D RealVector3D::operator*(const float other) const 122 | { 123 | return RealVector3D(I * other, J * other, K * other); 124 | } 125 | 126 | RealVector3D operator*(const float a, const RealVector3D &b) 127 | { 128 | return RealVector3D(a * b.I, a * b.J, a * b.K); 129 | } 130 | 131 | RealVector3D &RealVector3D::operator/=(const RealVector3D &other) 132 | { 133 | I /= other.I; 134 | J /= other.J; 135 | K /= other.K; 136 | 137 | return *this; 138 | } 139 | 140 | RealVector3D &RealVector3D::operator/=(const float other) 141 | { 142 | I /= other; 143 | J /= other; 144 | K /= other; 145 | 146 | return *this; 147 | } 148 | 149 | RealVector3D RealVector3D::operator/(const RealVector3D &other) const 150 | { 151 | return RealVector3D(I / other.I, J / other.J, K / other.K); 152 | } 153 | 154 | RealVector3D RealVector3D::operator/(const float other) const 155 | { 156 | return RealVector3D(I / other, J / other, K / other); 157 | } 158 | 159 | RealVector3D operator/(const float a, const RealVector3D &b) 160 | { 161 | return RealVector3D(a / b.I, a / b.J, a / b.K); 162 | } 163 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/RealVector3D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Blam::Math 4 | { 5 | struct RealVector3D 6 | { 7 | float I; 8 | float J; 9 | float K; 10 | 11 | RealVector3D(); 12 | RealVector3D(const float i, const float j, const float k); 13 | 14 | bool operator==(const RealVector3D &other) const; 15 | bool operator!=(const RealVector3D &other) const; 16 | 17 | explicit operator const float *() const; 18 | 19 | RealVector3D &operator+=(const RealVector3D &other); 20 | RealVector3D &operator+=(const float other); 21 | RealVector3D operator+(const RealVector3D &other) const; 22 | RealVector3D operator+(const float other) const; 23 | friend RealVector3D operator+(const float a, const RealVector3D &b); 24 | 25 | RealVector3D &operator-=(const RealVector3D &other); 26 | RealVector3D &operator-=(const float other); 27 | RealVector3D operator-(const RealVector3D &other) const; 28 | RealVector3D operator-(const float other) const; 29 | friend RealVector3D operator-(const float a, const RealVector3D &b); 30 | 31 | RealVector3D &operator*=(const RealVector3D &other); 32 | RealVector3D &operator*=(const float other); 33 | RealVector3D operator*(const RealVector3D &other) const; 34 | RealVector3D operator*(const float other) const; 35 | friend RealVector3D operator*(const float a, const RealVector3D &b); 36 | 37 | RealVector3D &operator/=(const RealVector3D &other); 38 | RealVector3D &operator/=(const float other); 39 | RealVector3D operator/(const RealVector3D &other) const; 40 | RealVector3D operator/(const float other) const; 41 | friend RealVector3D operator/(const float a, const RealVector3D &b); 42 | }; 43 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/Rectangle2D.cpp: -------------------------------------------------------------------------------- 1 | #include "Rectangle2D.hpp" 2 | 3 | namespace Blam::Math 4 | { 5 | Rectangle2D::Rectangle2D() 6 | : Rectangle2D(0, 0, 0, 0) 7 | { 8 | } 9 | 10 | Rectangle2D::Rectangle2D(const int16_t top, const int16_t left, const int16_t bottom, const int16_t right) 11 | : Top(top), Left(left), Bottom(bottom), Right(right) 12 | { 13 | } 14 | 15 | bool Rectangle2D::operator==(const Rectangle2D &other) const 16 | { 17 | return Top == other.Top 18 | && Left == other.Left 19 | && Bottom == other.Bottom 20 | && Right == other.Right; 21 | } 22 | 23 | bool Rectangle2D::operator!=(const Rectangle2D &other) const 24 | { 25 | return !(*this == other); 26 | } 27 | 28 | Rectangle2D::operator const int16_t *() const 29 | { 30 | return &Top; 31 | } 32 | 33 | Rectangle2D &Rectangle2D::operator+=(const Rectangle2D &other) 34 | { 35 | Top += other.Top; 36 | Left += other.Left; 37 | Bottom += other.Bottom; 38 | Right += other.Right; 39 | 40 | return *this; 41 | } 42 | 43 | Rectangle2D &Rectangle2D::operator+=(const int16_t other) 44 | { 45 | Top += other; 46 | Left += other; 47 | Bottom += other; 48 | Right += other; 49 | 50 | return *this; 51 | } 52 | 53 | Rectangle2D Rectangle2D::operator+(const Rectangle2D &other) const 54 | { 55 | return Rectangle2D(Top + other.Top, Left + other.Left, Bottom + other.Bottom, Right + other.Right); 56 | } 57 | 58 | Rectangle2D Rectangle2D::operator+(const int16_t other) const 59 | { 60 | return Rectangle2D(Top + other, Left + other, Bottom + other, Right + other); 61 | } 62 | 63 | Rectangle2D operator+(const int16_t a, const Rectangle2D &b) 64 | { 65 | return Rectangle2D(a + b.Top, a + b.Left, a + b.Bottom, a + b.Right); 66 | } 67 | 68 | Rectangle2D &Rectangle2D::operator-=(const Rectangle2D &other) 69 | { 70 | Top -= other.Top; 71 | Left -= other.Left; 72 | Bottom -= other.Bottom; 73 | Right -= other.Right; 74 | 75 | return *this; 76 | } 77 | 78 | Rectangle2D &Rectangle2D::operator-=(const int16_t other) 79 | { 80 | Top -= other; 81 | Left -= other; 82 | Bottom -= other; 83 | Right -= other; 84 | 85 | return *this; 86 | } 87 | 88 | Rectangle2D Rectangle2D::operator-(const Rectangle2D &other) const 89 | { 90 | return Rectangle2D(Top - other.Top, Left - other.Left, Bottom - other.Bottom, Right - other.Right); 91 | } 92 | 93 | Rectangle2D Rectangle2D::operator-(const int16_t other) const 94 | { 95 | return Rectangle2D(Top - other, Left - other, Bottom - other, Right - other); 96 | } 97 | 98 | Rectangle2D operator-(const int16_t a, const Rectangle2D &b) 99 | { 100 | return Rectangle2D(a - b.Top, a - b.Left, a - b.Bottom, a - b.Right); 101 | } 102 | 103 | Rectangle2D &Rectangle2D::operator*=(const Rectangle2D &other) 104 | { 105 | Top *= other.Top; 106 | Left *= other.Left; 107 | Bottom *= other.Bottom; 108 | Right *= other.Right; 109 | 110 | return *this; 111 | } 112 | 113 | Rectangle2D &Rectangle2D::operator*=(const int16_t other) 114 | { 115 | Top *= other; 116 | Left *= other; 117 | Bottom *= other; 118 | Right *= other; 119 | 120 | return *this; 121 | } 122 | 123 | Rectangle2D Rectangle2D::operator*(const Rectangle2D &other) const 124 | { 125 | return Rectangle2D(Top * other.Top, Left * other.Left, Bottom * other.Bottom, Right * other.Right); 126 | } 127 | 128 | Rectangle2D Rectangle2D::operator*(const int16_t other) const 129 | { 130 | return Rectangle2D(Top * other, Left * other, Bottom * other, Right * other); 131 | } 132 | 133 | Rectangle2D operator*(const int16_t a, const Rectangle2D &b) 134 | { 135 | return Rectangle2D(a * b.Top, a * b.Left, a * b.Bottom, a * b.Right); 136 | } 137 | 138 | Rectangle2D &Rectangle2D::operator/=(const Rectangle2D &other) 139 | { 140 | Top /= other.Top; 141 | Left /= other.Left; 142 | Bottom /= other.Bottom; 143 | Right /= other.Right; 144 | 145 | return *this; 146 | } 147 | 148 | Rectangle2D &Rectangle2D::operator/=(const int16_t other) 149 | { 150 | Top /= other; 151 | Left /= other; 152 | Bottom /= other; 153 | Right /= other; 154 | 155 | return *this; 156 | } 157 | 158 | Rectangle2D Rectangle2D::operator/(const Rectangle2D &other) const 159 | { 160 | return Rectangle2D(Top / other.Top, Left / other.Left, Bottom / other.Bottom, Right / other.Right); 161 | } 162 | 163 | Rectangle2D Rectangle2D::operator/(const int16_t other) const 164 | { 165 | return Rectangle2D(Top / other, Left / other, Bottom / other, Right / other); 166 | } 167 | 168 | Rectangle2D operator/(const int16_t a, const Rectangle2D &b) 169 | { 170 | return Rectangle2D(a / b.Top, a / b.Left, a / b.Bottom, a / b.Right); 171 | } 172 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Math/Rectangle2D.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Math 5 | { 6 | struct Rectangle2D 7 | { 8 | int16_t Top; 9 | int16_t Left; 10 | int16_t Bottom; 11 | int16_t Right; 12 | 13 | Rectangle2D(); 14 | Rectangle2D(const int16_t top, const int16_t left, const int16_t bottom, const int16_t right); 15 | 16 | bool operator==(const Rectangle2D &other) const; 17 | bool operator!=(const Rectangle2D &other) const; 18 | 19 | explicit operator const int16_t *() const; 20 | 21 | Rectangle2D &operator+=(const Rectangle2D &other); 22 | Rectangle2D &operator+=(const int16_t other); 23 | Rectangle2D operator+(const Rectangle2D &other) const; 24 | Rectangle2D operator+(const int16_t other) const; 25 | friend Rectangle2D operator+(const int16_t a, const Rectangle2D &b); 26 | 27 | Rectangle2D &operator-=(const Rectangle2D &other); 28 | Rectangle2D &operator-=(const int16_t other); 29 | Rectangle2D operator-(const Rectangle2D &other) const; 30 | Rectangle2D operator-(const int16_t other) const; 31 | friend Rectangle2D operator-(const int16_t a, const Rectangle2D &b); 32 | 33 | Rectangle2D &operator*=(const Rectangle2D &other); 34 | Rectangle2D &operator*=(const int16_t other); 35 | Rectangle2D operator*(const Rectangle2D &other) const; 36 | Rectangle2D operator*(const int16_t other) const; 37 | friend Rectangle2D operator*(const int16_t a, const Rectangle2D &b); 38 | 39 | Rectangle2D &operator/=(const Rectangle2D &other); 40 | Rectangle2D &operator/=(const int16_t other); 41 | Rectangle2D operator/(const Rectangle2D &other) const; 42 | Rectangle2D operator/(const int16_t other) const; 43 | friend Rectangle2D operator/(const int16_t a, const Rectangle2D &b); 44 | }; 45 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Memory/GlobalMemoryMap.cpp: -------------------------------------------------------------------------------- 1 | #include "GlobalMemoryMap.hpp" 2 | 3 | namespace Blam::Memory 4 | { 5 | GlobalMemoryMapStage::GlobalMemoryMapStage() 6 | : DataAddress(nullptr), CacheAddress(nullptr) 7 | { 8 | } 9 | 10 | GlobalMemoryMap::GlobalMemoryMap() 11 | : Allocator(nullptr), DataBaseAddress(nullptr), CacheBaseAddress(nullptr) 12 | { 13 | } 14 | 15 | GlobalMemoryMap* GlobalMemoryMap::Instance() 16 | { 17 | return reinterpret_cast(0x238EC50); 18 | } 19 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Memory/GlobalMemoryMap.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Memory 5 | { 6 | struct GlobalMemoryMapStage 7 | { 8 | char* DataAddress; 9 | char* CacheAddress; 10 | uint32_t IsInitialized; 11 | uint32_t DataAllocationCount; 12 | uint32_t CacheAllocationCount; 13 | 14 | GlobalMemoryMapStage(); 15 | }; 16 | 17 | struct GlobalMemoryMap 18 | { 19 | void** Allocator; 20 | uint32_t CurrentStageIndex; 21 | char* DataBaseAddress; 22 | char* CacheBaseAddress; 23 | uint32_t IsInitialized; 24 | GlobalMemoryMapStage Stages[8]; 25 | 26 | GlobalMemoryMap(); 27 | 28 | static GlobalMemoryMap *Instance(); 29 | }; 30 | static_assert(sizeof(GlobalMemoryMap) == 0xB4, "Blam::Memory::GlobalMemoryMap"); 31 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Objects/ObjectData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Globals.hpp" 4 | #include "Blam\Data\DataArray.hpp" 5 | #include "Blam\Data\DatumBase.hpp" 6 | #include "Blam\Data\DatumIndex.hpp" 7 | #include "ObjectType.hpp" 8 | 9 | namespace Blam::Objects 10 | { 11 | struct ObjectData : Data::DatumBase 12 | { 13 | uint8_t Flags; 14 | ObjectType Type : 8; 15 | uint32_t Unknown8; 16 | uint32_t PoolOffset; 17 | void *Data; 18 | 19 | ObjectData() 20 | : Type(ObjectType::None), Data(nullptr) 21 | { 22 | } 23 | 24 | static const Data::DataArray *GetDataArray() 25 | { 26 | return AnvilCommon::GetThreadStorage>(0x448); 27 | } 28 | 29 | Data::DatumIndex GetTagIndex() const 30 | { 31 | using Blam::Data::DatumIndex; 32 | 33 | if (!Data) 34 | return DatumIndex::Null; 35 | 36 | return *static_cast(Data); 37 | } 38 | }; 39 | static_assert(sizeof(ObjectData) == 0x10, "Blam::Objects::ObjectData"); 40 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Objects/ObjectType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Objects 5 | { 6 | enum class ObjectType : int8_t 7 | { 8 | None = -1, 9 | Biped, 10 | Vehicle, 11 | Weapon, 12 | Equipment, 13 | ArgDevice, 14 | Terminal, 15 | Projectile, 16 | Scenery, 17 | Machine, 18 | Control, 19 | SoundScenery, 20 | Crate, 21 | Creature, 22 | Giant, 23 | EffectScenery 24 | }; 25 | static_assert(sizeof(ObjectType) == 0x1, "Blam::Objects::ObjectType"); 26 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Sounds/Noise.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Tags::Sounds 5 | { 6 | enum class NoiseLevel : int16_t 7 | { 8 | Silent, 9 | Medium, 10 | Loud, 11 | Shout, 12 | Quiet 13 | }; 14 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/Game/CacheFileGlobalTags.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Blam\Tags\TagBlock.hpp" 4 | #include "Blam\Tags\TagReference.hpp" 5 | 6 | namespace Blam::Tags::Game 7 | { 8 | struct CacheFileGlobalTags 9 | { 10 | TagBlock GlobalTags; 11 | int32_t : 32; 12 | }; 13 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/Game/VFilesList.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "../TagBlock.hpp" 5 | #include "../TagData.hpp" 6 | 7 | namespace Blam::Tags::Game 8 | { 9 | // Contains a list of vfiles 10 | struct VFilesList 11 | { 12 | // Contains information about a vfile 13 | struct VFileInfo 14 | { 15 | char Name[256]; // The name of the file (e.g. "hf2p_weapons_categories.ps") 16 | char Folder[256]; // The folder the file is located in (e.g. "ps\autogen\") 17 | int32_t Offset; // The starting offset of the file from the file data block 18 | int32_t Size; // The size of the file in bytes 19 | }; 20 | 21 | TagBlock Files; // The files in the list 22 | TagData Data; // The data block containing the data for every file 23 | }; 24 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/Items/Item.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../Math/Bounds.hpp" 3 | #include "../TagBlock.hpp" 4 | #include "../TagData.hpp" 5 | #include "../TagReference.hpp" 6 | #include "../../Text/StringID.hpp" 7 | #include "../Objects/Object.hpp" 8 | 9 | namespace Blam::Tags::Items 10 | { 11 | using Blam::Math::Bounds; 12 | using Blam::Tags::TagBlock; 13 | using Blam::Tags::TagReference; 14 | using Blam::Text::StringID; 15 | using Blam::Tags::Objects::Object; 16 | 17 | struct Item : Object 18 | { 19 | enum class Flags : int32_t; 20 | struct PredictedBitmap; 21 | 22 | Item::Flags ItemFlags : 32; 23 | short : 16; // old message index 24 | int16_t SortOrder; 25 | long : 32; // old multiplayer on-ground scale 26 | long : 32; // old single player on-ground scale 27 | StringID PickupMessage; 28 | StringID SwapMessage; 29 | StringID PickupOrDualWieldMessage; 30 | StringID SwapOrDualWieldMessage; 31 | StringID PickedUpMessage; 32 | StringID SwitchToMessage; 33 | StringID SwitchToFromAIMessage; 34 | StringID AllWeaponsEmptyMessage; 35 | TagReference CollisionSound; 36 | TagBlock PredictedBitmaps; 37 | TagReference DetonationDamageEffect; 38 | Bounds DetonationDelayBounds; 39 | TagReference DetonatingEffect; 40 | TagReference DetonationEffect; 41 | float GroundScaleSP; 42 | float GroundScaleMP; 43 | float SmallHoldScale; 44 | float SmallHolsterScale; 45 | float MediumHoldScale; 46 | float MediumHolsterScale; 47 | float LargeHoldScale; 48 | float LargeHolsterScale; 49 | float HugeHoldScale; 50 | float HugeHolsterScale; 51 | float GroundedFrictionLength; 52 | float GroundedFrictionUnknown; 53 | 54 | enum class Item::Flags : int32_t 55 | { 56 | None, 57 | AlwaysMaintainsZUp = 1 << 0, 58 | DestroyedByExplosions = 1 << 1, 59 | UnaffectedByGravity = 1 << 2 60 | }; 61 | 62 | struct Item::PredictedBitmap 63 | { 64 | TagReference Bitmap; 65 | }; 66 | static_assert(sizeof(Item::PredictedBitmap) == 0x10, ""); 67 | }; 68 | static_assert(sizeof(Item) == 0x1D4, ""); 69 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/Tag.cpp: -------------------------------------------------------------------------------- 1 | #include "Tag.hpp" 2 | 3 | namespace Blam::Tags 4 | { 5 | const Tag Tag::Null = 0xFFFFFFFF; 6 | 7 | Tag::Tag() 8 | : Tag(Null) 9 | { 10 | } 11 | 12 | Tag::Tag(const uint32_t p_Value) 13 | : Value(p_Value) 14 | { 15 | } 16 | 17 | Tag::Tag(const Tag &p_Other) 18 | : Tag(p_Other.Value) 19 | { 20 | } 21 | 22 | bool Tag::operator==(const Tag &p_Other) const 23 | { 24 | return Value == p_Other.Value; 25 | } 26 | 27 | bool Tag::operator!=(const Tag &p_Other) const 28 | { 29 | return !(*this == p_Other); 30 | } 31 | 32 | Tag::operator uint32_t() const 33 | { 34 | return Value; 35 | } 36 | 37 | Tag::operator bool() const 38 | { 39 | return *this != Null; 40 | } 41 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/Tag.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Tags 5 | { 6 | struct Tag 7 | { 8 | static const Tag Null; 9 | 10 | uint32_t Value; 11 | 12 | Tag(); 13 | Tag(const uint32_t p_Value); 14 | Tag(const Tag &p_Other); 15 | 16 | bool operator==(const Tag &p_Other) const; 17 | bool operator!=(const Tag &p_Other) const; 18 | 19 | explicit operator uint32_t() const; 20 | 21 | explicit operator bool() const; 22 | }; 23 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/TagBlock.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Tags 5 | { 6 | template 7 | struct TagBlock 8 | { 9 | int32_t Count; 10 | Element *Elements; 11 | unsigned : 32; 12 | 13 | TagBlock(const int32_t p_Count, Element *const p_Elements) 14 | : Count(p_Count), Elements(p_Elements) 15 | { 16 | } 17 | 18 | TagBlock() 19 | : TagBlock(0, nullptr) 20 | { 21 | } 22 | 23 | Element *operator->() const 24 | { 25 | return Elements; 26 | } 27 | 28 | inline Element *begin() const 29 | { 30 | return Elements; 31 | } 32 | 33 | inline Element *end() const 34 | { 35 | return &Elements[Count]; 36 | } 37 | 38 | Element &operator[](const size_t p_Index) const 39 | { 40 | return Elements[p_Index]; 41 | } 42 | 43 | explicit operator bool() const 44 | { 45 | return (Count > 0) 46 | && (Elements != nullptr); 47 | } 48 | }; 49 | static_assert(sizeof(TagBlock) == 0xC, "Blam::Tags::TagBlock<>"); 50 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/TagData.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Tags 5 | { 6 | template 7 | struct TagData 8 | { 9 | int32_t Size; 10 | long : 32; 11 | long : 32; 12 | Element *Elements; 13 | long : 32; 14 | 15 | TagData(const int32_t p_Size, Element *const p_Elements) 16 | : Size(p_Size), Elements(p_Elements) 17 | { 18 | } 19 | 20 | TagData() 21 | : TagData(0, nullptr) 22 | { 23 | } 24 | 25 | Element *operator->() const 26 | { 27 | return Elements; 28 | } 29 | 30 | inline Element *begin() const 31 | { 32 | return Elements; 33 | } 34 | 35 | inline Element *end() const 36 | { 37 | return &Elements[Count]; 38 | } 39 | 40 | Element &operator[](const size_t p_Index) const 41 | { 42 | return Elements[p_Index]; 43 | } 44 | 45 | explicit operator bool() const 46 | { 47 | return (Size > 0) 48 | && (Elements != nullptr); 49 | } 50 | }; 51 | static_assert(sizeof(TagData) == 0x14, "Blam::Tags::TagData<>"); 52 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/TagInstance.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Blam::Tags 5 | { 6 | struct TagInstance 7 | { 8 | uint16_t Index; 9 | 10 | TagInstance(const uint16_t p_Index) : Index(p_Index) {} 11 | TagInstance() : TagInstance(0xFFFF) {} 12 | 13 | uint32_t GetGroupTag() { return reinterpret_cast(0x5033A0)(Index); } 14 | 15 | template 16 | T *GetDefinition() 17 | { 18 | if (Index == 0xFFFF) 19 | return nullptr; 20 | 21 | return reinterpret_cast(reinterpret_cast(0x503370)(GetGroupTag(), Index)); 22 | } 23 | }; 24 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Tags/TagReference.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Tag.hpp" 4 | 5 | namespace Blam::Tags 6 | { 7 | struct TagReference 8 | { 9 | Tag GroupTag; 10 | int32_t : 32; 11 | int32_t : 32; 12 | int32_t TagIndex; 13 | 14 | TagReference(const Tag &p_GroupTag, const int32_t p_TagIndex) 15 | : GroupTag(p_GroupTag), TagIndex(p_TagIndex) 16 | { 17 | } 18 | 19 | TagReference() 20 | : TagReference(Tag::Null, -1) 21 | { 22 | } 23 | 24 | bool operator==(const TagReference &p_Other) const 25 | { 26 | return (GroupTag == p_Other.GroupTag) 27 | && (TagIndex == p_Other.TagIndex); 28 | } 29 | 30 | bool operator!=(const TagReference &p_Other) const 31 | { 32 | return !(*this == p_Other); 33 | } 34 | 35 | explicit operator bool() const 36 | { 37 | return (GroupTag != Tag::Null) 38 | && (TagIndex >= 0); 39 | } 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Text/StringID.cpp: -------------------------------------------------------------------------------- 1 | #include "Blam\Cache\StringIDCacheHeader.hpp" 2 | #include "StringID.hpp" 3 | 4 | namespace Blam::Text 5 | { 6 | const StringID StringID::Null = 0; 7 | 8 | StringID::StringID() : StringID(Null) {} 9 | 10 | StringID::StringID(const int32_t p_Length, const int32_t p_Set, const int32_t p_Index) 11 | : Value((uint32_t)(((p_Length & 0xFF) << 24) | ((p_Set & 0xFF) << 16) | (p_Index & 0xFFFF))) 12 | { 13 | } 14 | 15 | StringID::StringID(const int32_t p_Set, const int32_t p_Index) 16 | : StringID(0, p_Set, p_Index) 17 | { 18 | } 19 | 20 | StringID::StringID(const uint32_t p_Value) 21 | : Value(p_Value) 22 | { 23 | } 24 | 25 | int32_t StringID::GetLength() const 26 | { 27 | return (int32_t)((Value >> 24) & 0xFF); 28 | } 29 | 30 | int32_t StringID::GetSet() const 31 | { 32 | return (int32_t)((Value >> 16) & 0xFF); 33 | } 34 | 35 | int32_t StringID::GetIndex() const 36 | { 37 | return (int32_t)(Value & 0xFFFF); 38 | } 39 | 40 | bool StringID::operator<(const StringID &p_Other) const 41 | { 42 | return Value < p_Other.Value; 43 | } 44 | 45 | bool StringID::operator>(const StringID &p_Other) const 46 | { 47 | return Value > p_Other.Value; 48 | } 49 | 50 | bool StringID::operator<=(const StringID &p_Other) const 51 | { 52 | return Value <= p_Other.Value; 53 | } 54 | 55 | bool StringID::operator>=(const StringID &p_Other) const 56 | { 57 | return Value >= p_Other.Value; 58 | } 59 | 60 | bool StringID::operator==(const StringID &p_Other) const 61 | { 62 | return Value == p_Other.Value; 63 | } 64 | 65 | bool StringID::operator!=(const StringID &p_Other) const 66 | { 67 | return !(*this == p_Other); 68 | } 69 | 70 | bool StringID::operator==(const std::string &p_Other) const 71 | { 72 | return false; 73 | // TODO: Implement 74 | //return p_Other == Cache::StringIDCache::Instance()->GetString(*this); 75 | } 76 | 77 | bool StringID::operator!=(const std::string &p_Other) const 78 | { 79 | return !(*this == p_Other); 80 | } 81 | 82 | StringID::operator std::string() const 83 | { 84 | return std::string(); 85 | // TODO: Implement 86 | //return Cache::StringIDCache::Instance()->GetString(*this); 87 | } 88 | 89 | StringID::operator uint32_t() const 90 | { 91 | return Value; 92 | } 93 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Blam/Text/StringID.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace Blam::Text 6 | { 7 | /// 8 | /// A constant ID representing a debug string. 9 | /// 10 | struct StringID 11 | { 12 | static const StringID Null; 13 | 14 | uint32_t Value; 15 | 16 | StringID(); 17 | StringID(const uint32_t p_Value); 18 | StringID(const int32_t p_Set, const int32_t p_Index); 19 | StringID(const int32_t p_Length, const int32_t p_Set, const int32_t p_Index); 20 | 21 | int32_t GetLength() const; 22 | int32_t GetSet() const; 23 | int32_t GetIndex() const; 24 | 25 | bool operator<(const StringID &p_Other) const; 26 | bool operator>(const StringID &p_Other) const; 27 | 28 | bool operator<=(const StringID &p_Other) const; 29 | bool operator>=(const StringID &p_Other) const; 30 | 31 | bool operator==(const StringID &p_Other) const; 32 | bool operator!=(const StringID &p_Other) const; 33 | 34 | bool operator==(const std::string &p_Other) const; 35 | bool operator!=(const std::string &p_Other) const; 36 | 37 | explicit operator std::string() const; 38 | 39 | explicit operator uint32_t() const; 40 | }; 41 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Camera.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Blam\Math\RealPoint3D.hpp" 5 | #include "Blam\Math\RealVector2D.hpp" 6 | #include "Blam\Math\RealVector3D.hpp" 7 | 8 | namespace AnvilEldorado 9 | { 10 | enum class CameraMode 11 | { 12 | FirstPerson, 13 | Following, 14 | Flying, 15 | Static 16 | }; 17 | 18 | enum class CameraDefinitionType : int32_t 19 | { 20 | Position = 0, 21 | PositionShift = 1, 22 | LookShift = 2, 23 | Depth = 3, 24 | FieldOfView = 4, 25 | LookVectors = 5 26 | }; 27 | 28 | struct CameraGlobals 29 | { 30 | uint32_t Unknown1; 31 | void *UpdatePerspectiveFunction; 32 | uint8_t Unknown2[0x830]; 33 | Blam::Math::RealPoint3D Position; 34 | Blam::Math::RealVector3D PositionShift; 35 | Blam::Math::RealVector2D LookShift; 36 | float Depth; 37 | float FieldOfView; 38 | Blam::Math::RealVector3D Forward; 39 | Blam::Math::RealVector2D Up; 40 | }; 41 | 42 | class Camera : 43 | public AnvilCommon::Initializable 44 | { 45 | public: 46 | static CameraGlobals *GetCameraGlobals(); 47 | 48 | virtual bool Init(); 49 | 50 | CameraMode GetCameraMode() const; 51 | void SetCameraMode(const CameraMode &p_Mode); 52 | 53 | bool IsHudVisible() const; 54 | void SetHudVisible(const bool p_Visible = true); 55 | 56 | bool IsReticleCentered() const; 57 | void SetReticleCentered(const bool p_Centered = true); 58 | 59 | float GetSpeed() const; 60 | void SetSpeed(const float p_Speed); 61 | 62 | float GetFieldOfView() const; 63 | void SetFieldOfView(const float p_FieldOfView); 64 | 65 | Blam::Math::RealPoint3D GetPosition() const; 66 | void SetPosition(const Blam::Math::RealPoint3D &p_Position); 67 | void SetPosition(const float p_X, const float p_Y, const float p_Z); 68 | 69 | private: 70 | CameraMode m_CameraMode; 71 | }; 72 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Engine.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace AnvilEldorado 5 | { 6 | class Engine : 7 | public AnvilCommon::Initializable 8 | { 9 | public: 10 | bool Init() override; 11 | 12 | bool UnprotectMemory(); 13 | bool ApplyPatches(); 14 | 15 | bool OnTagsLoaded(); 16 | 17 | bool HasMainMenuShown() const; 18 | void SetMainMenuShown(const bool p_Shown = true); 19 | 20 | private: 21 | bool m_MainMenuShown = false; 22 | }; 23 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/EngineImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define _WIN32_MEAN_AND_LEAN 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | namespace AnvilEldorado 12 | { 13 | class EngineImpl : 14 | public AnvilCommon::Engine 15 | { 16 | private: 17 | void* m_ModuleBase; 18 | size_t m_ModuleSize; 19 | 20 | protected: 21 | /// 22 | /// Create Window Hook 23 | /// 24 | DeclareFunction(HWND, __stdcall, CreateWindowExA, DWORD p_ExStyle, LPCSTR p_ClassName, LPCSTR p_WindowName, DWORD p_Style, int p_X, int p_Y, int p_Width, int p_Height, HWND p_Parent, HMENU p_Menu, HINSTANCE p_Instance, LPVOID p_Param); 25 | 26 | /// 27 | /// Bink Video Hook 28 | /// 29 | DeclareFunction(bool, __cdecl, LoadBinkVideo, int p_VideoID, char *p_DestBuf); 30 | 31 | /// 32 | /// Tag Cache Validation Hook 33 | /// 34 | DeclareFunction(char, __cdecl, ValidateTagCache, void *a1); 35 | 36 | /// 37 | /// Account Processing Hook 38 | /// 39 | DeclareFunction(char*, __cdecl, ProcessAccountInfo); 40 | 41 | /// 42 | /// Account Verification Hook 43 | /// 44 | DeclareFunction(char, __cdecl, VerifyAccountAndLoadAnticheat); 45 | 46 | /// 47 | /// Force Russian Localization Hook 48 | /// 49 | DeclareFunction(char, __cdecl, ForceRussianLocale); 50 | 51 | /// 52 | /// On Tags Loaded Hook 53 | /// 54 | DeclareFunction(signed int, __cdecl, OnTagsLoaded, int); 55 | 56 | public: 57 | EngineImpl(); 58 | ~EngineImpl(); 59 | 60 | virtual bool Init(); 61 | virtual uint8_t* ExecutableBase(); 62 | virtual size_t ExecutableSize(); 63 | 64 | private: 65 | void CreateHooks(); 66 | }; 67 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Forge.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace AnvilEldorado 5 | { 6 | class Forge : 7 | public AnvilCommon::Initializable 8 | { 9 | public: 10 | virtual bool Init(); 11 | 12 | void UpdateBarriersEnabled(); 13 | 14 | bool ShouldDelete() const; 15 | void SetShouldDelete(const bool p_ShouldDelete = true); 16 | 17 | bool BarriersEnabledValid() const; 18 | void SetBarriersEnabledValid(const bool p_Valid = true); 19 | 20 | bool KillBarriersEnabled() const; 21 | void SetKillBarriersEnabled(const bool p_Enabled = true); 22 | 23 | bool PushBarriersEnabled() const; 24 | void SetPushBarriersEnabled(const bool p_Enabled = true); 25 | 26 | private: 27 | bool m_BarriersEnabledValid = false; 28 | bool m_KillBarriersEnabled = true; 29 | bool m_PushBarriersEnabled = true; 30 | }; 31 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Audio/AudioImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "AudioImpl.hpp" 2 | #include "Hooks.hpp" 3 | 4 | using namespace AnvilEldorado::Game::Audio; 5 | 6 | bool AudioImpl::Init() 7 | { 8 | m_Hooks = std::make_shared(); 9 | if (!m_Hooks->Init()) 10 | return false; 11 | 12 | return true; 13 | } 14 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Audio/AudioImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace AnvilEldorado::Game::Audio 6 | { 7 | class AudioImpl : 8 | public AnvilCommon::Initializable 9 | { 10 | private: 11 | std::shared_ptr m_Hooks; 12 | public: 13 | virtual bool Init(); 14 | }; 15 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Audio/Hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "Hooks.hpp" 2 | #include 3 | #include 4 | 5 | using namespace AnvilEldorado::Game::Audio; 6 | 7 | bool Hooks::Init() 8 | { 9 | auto s_Base = GetClientInterface()->GetEngine()->ExecutableBase(); 10 | 11 | // Hook FMOD::System::Init 12 | auto s_Address = s_Base + 0xF69AA0; 13 | HookFunctionOffset(s_Address, FMOD_System_Init); 14 | 15 | // Hook FMOD::System::SetSoftwareChannels 16 | s_Address = s_Base + 0xF88880; 17 | HookFunctionOffset(s_Address, FMOD_System_SetSoftwareChannels); 18 | 19 | /* 20 | kiwidog notes - 21 | audioses.dll = 1001A1F0 22 | audioses + 1A1F0 23 | takes 3 arguments 24 | last is the 0, that we need to change to a 1 25 | Don't hardcode this, try and attempt to find where/how to patch properly...This may be the only patch hopefully 26 | */ 27 | return true; 28 | } 29 | 30 | DeclareDetouredFunction(Hooks, void*, __stdcall, FMOD_System_Init, void* a1, int maxChannels, void* a3, void* a4, void* a5) 31 | { 32 | WriteLog("Max channels changed from %d to %d", maxChannels, 256); 33 | 34 | return o_FMOD_System_Init(a1, 256, a3, a4, a5); 35 | } 36 | 37 | DeclareDetouredFunction(Hooks, void*, __stdcall, FMOD_System_SetSoftwareChannels, void* system, int numsoftwarechannels) 38 | { 39 | WriteLog("Max software channels changed from %d to %d.", numsoftwarechannels, 256); 40 | 41 | return o_FMOD_System_SetSoftwareChannels(system, 256); 42 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Audio/Hooks.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace AnvilEldorado::Game::Audio 6 | { 7 | class Hooks : 8 | public AnvilCommon::Initializable 9 | { 10 | protected: 11 | /// 12 | /// VTable Function from vtbl .rdata:01750794 ; const FMOD::EventSystemI::`vftable' 13 | /// .text:01369AA0 FMOD__System__init 14 | /// 15 | DeclareFunction(void*, __stdcall, FMOD_System_Init, void*, int maxChannels, void*, void*, void*); 16 | 17 | /// 18 | /// .text:01388880 FMOD_System_SetSoftwareChannels 19 | /// 20 | DeclareFunction(void*, __stdcall, FMOD_System_SetSoftwareChannels, void*, int); 21 | 22 | public: 23 | virtual bool Init(); 24 | }; 25 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Cache/StringIdCache.cpp: -------------------------------------------------------------------------------- 1 | #include "StringIdCache.hpp" 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | using namespace AnvilEldorado::Game::Cache; 10 | 11 | bool StringIdCache::Init() 12 | { 13 | // Parse the string_id file if it exists 14 | if (!ParseStringIds("maps\\string_ids.dat")) 15 | return false; 16 | 17 | return true; 18 | } 19 | 20 | bool StringIdCache::ParseStringIds(const std::string p_Path) 21 | { 22 | // Check if the file exists 23 | if (!std::experimental::filesystem::exists(p_Path)) 24 | return false; 25 | 26 | // Open a stream to our file 27 | std::ifstream s_Stream(p_Path, std::ios::binary); 28 | 29 | // Check if our stream is open 30 | if (!s_Stream.is_open()) 31 | return false; 32 | 33 | // Hold our header for parsing 34 | Blam::Cache::StringIDCacheHeader s_Header = { 0 }; 35 | 36 | // Read out the header 37 | s_Stream.read(reinterpret_cast(&s_Header), sizeof(s_Header)); 38 | 39 | // Create new data to hold our offsets 40 | auto s_Offsets = std::shared_ptr(new int32_t[s_Header.Count], std::default_delete()); 41 | // TODO: Determine if we need to set everything to -1? 42 | 43 | // Create memory to hold all of our strings 44 | auto s_Strings = std::shared_ptr(new char[s_Header.Size + 1], std::default_delete()); 45 | std::memset(s_Strings.get(), 0, s_Header.Size + 1); 46 | 47 | // Read all of our offsets 48 | s_Stream.read(reinterpret_cast(s_Offsets.get()), sizeof(int32_t) * s_Header.Count); 49 | 50 | // Read all of our strings 51 | s_Stream.read(reinterpret_cast(s_Strings.get()), s_Header.Size); 52 | 53 | // We are finished with the stream 54 | s_Stream.close(); 55 | 56 | // Assign all of our strings to the map for future access 57 | for (auto i = 0; i < s_Header.Count; ++i) 58 | { 59 | auto l_Offset = s_Offsets.get()[i]; 60 | 61 | // Ignore Blam "null" values, and out of range values 62 | if (l_Offset < 0 || l_Offset > s_Header.Size) 63 | { 64 | WriteLog("string_id out of range! index: %d offset: %d", i, l_Offset); 65 | continue; 66 | } 67 | 68 | // Add our string to the list 69 | m_Strings.insert_or_assign(i, std::string(s_Strings.get() + l_Offset)); 70 | } 71 | 72 | // Some output logging 73 | WriteLog("Read %d string_id's from %s.", Count(), p_Path.c_str()); 74 | 75 | // shared_ptr should free the rest of the memory we used 76 | return true; 77 | } 78 | 79 | std::string StringIdCache::GetString(int16_t p_Id) 80 | { 81 | // Bounds checking 82 | if (p_Id > Count()) 83 | return std::string(); 84 | 85 | // Return our string 86 | return m_Strings[p_Id]; 87 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Cache/StringIdCache.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace AnvilEldorado::Game::Cache 7 | { 8 | class StringIdCache : 9 | public AnvilCommon::Initializable 10 | { 11 | protected: 12 | std::unordered_map m_Strings; 13 | 14 | private: 15 | bool ParseStringIds(const std::string p_Path); 16 | 17 | public: 18 | virtual bool Init(); 19 | 20 | virtual bool Empty() { return m_Strings.empty(); } 21 | virtual int32_t Count() { return m_Strings.size(); } 22 | virtual std::string GetString(int16_t p_Id); 23 | }; 24 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Input/InputImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "InputImpl.hpp" 2 | 3 | #include 4 | #include 5 | 6 | using namespace AnvilEldorado::Game::Input; 7 | using namespace Blam::Input; 8 | 9 | bool InputImpl::Init() 10 | { 11 | // TODO: Init 12 | return true; 13 | } 14 | 15 | uint8_t InputImpl::GetKeyTicks(KeyCode key, InputType type) 16 | { 17 | typedef uint8_t(*EngineGetKeyTicksPtr)(KeyCode, InputType); 18 | auto EngineGetKeyTicks = reinterpret_cast(0x511B60); 19 | return EngineGetKeyTicks(key, type); 20 | } 21 | 22 | uint16_t InputImpl::GetKeyMs(KeyCode key, InputType type) 23 | { 24 | typedef uint8_t(*EngineGetKeyMsPtr)(KeyCode, InputType); 25 | auto EngineGetKeyMs = reinterpret_cast(0x511CE0); 26 | return EngineGetKeyMs(key, type); 27 | } 28 | 29 | bool InputImpl::ReadKeyEvent(KeyEvent* result, InputType type) 30 | { 31 | typedef bool(*EngineReadKeyEventPtr)(KeyEvent*, InputType); 32 | auto EngineReadKeyEvent = reinterpret_cast(0x5118C0); 33 | return EngineReadKeyEvent(result, type); 34 | } 35 | 36 | void InputImpl::BlockInput(InputType type, bool block) 37 | { 38 | typedef uint8_t(*EngineBlockInputPtr)(InputType, bool); 39 | auto EngineBlockInput = reinterpret_cast(0x512530); 40 | EngineBlockInput(type, block); 41 | } 42 | 43 | bool InputImpl::GetBindings(int localPlayerIndex, BindingsTable *result) 44 | { 45 | if (localPlayerIndex < 0 || localPlayerIndex >= 4) 46 | return false; 47 | typedef void(*EngineGetBindingsPtr)(int localPlayerIndex, BindingsTable *result); 48 | auto EngineGetBindings = reinterpret_cast(0x60BE70); 49 | EngineGetBindings(localPlayerIndex, result); 50 | return true; 51 | } 52 | 53 | bool InputImpl::SetBindings(int localPlayerIndex, const BindingsTable &newBindings) 54 | { 55 | if (localPlayerIndex < 0 || localPlayerIndex >= 4) 56 | return false; 57 | typedef void(*EngineSetBindingsPtr)(int localPlayerIndex, const BindingsTable &newBindings); 58 | auto EngineSetBindings = reinterpret_cast(0x60D830); 59 | EngineSetBindings(localPlayerIndex, newBindings); 60 | return true; 61 | } 62 | 63 | Blam::Input::ActionState* InputImpl::GetActionState(Blam::Input::GameAction action) 64 | { 65 | if (action < 0 || action >= eGameAction_KeyboardMouseCount) 66 | return nullptr; 67 | auto actions = reinterpret_cast(0x244D1F0); 68 | return &actions[action]; 69 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Input/InputImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace Blam::Input 6 | { 7 | struct ActionState; 8 | struct BindingsTable; 9 | enum GameAction : uint8_t; 10 | enum InputType; 11 | enum KeyCode; 12 | enum KeyEvent; 13 | } 14 | 15 | namespace AnvilEldorado::Game::Input 16 | { 17 | class InputImpl : 18 | public AnvilCommon::Initializable 19 | { 20 | public: 21 | virtual bool Init(); 22 | 23 | uint8_t GetKeyTicks(Blam::Input::KeyCode key, Blam::Input::InputType type); 24 | uint16_t GetKeyMs(Blam::Input::KeyCode key, Blam::Input::InputType type); 25 | bool ReadKeyEvent(Blam::Input::KeyEvent* result, Blam::Input::InputType type); 26 | void BlockInput(Blam::Input::InputType type, bool block); 27 | bool GetBindings(int localPlayerIndex, Blam::Input::BindingsTable *result); 28 | bool SetBindings(int localPlayerIndex, const Blam::Input::BindingsTable &newBindings); 29 | Blam::Input::ActionState* GetActionState(Blam::Input::GameAction action); 30 | }; 31 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Networking/Hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "Hooks.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace AnvilEldorado::Game::Networking; 7 | 8 | bool Hooks::Init() 9 | { 10 | auto s_Base = GetClientInterface()->GetEngine()->ExecutableBase(); 11 | 12 | // Fix network debug strings having (null) instead of an IP address 13 | auto s_Address = s_Base + 0x3F6F0; 14 | HookFunctionOffset(s_Address, GetIPStringFromInAddr); 15 | 16 | // Fix for XnAddrToInAddr to try checking syslink-menu data for XnAddr->InAddr mapping before consulting XNet 17 | s_Address = s_Base + 0x12D840; 18 | HookFunctionOffset(s_Address, XnAddrToInAddr); 19 | 20 | return true; 21 | } 22 | 23 | DeclareDetouredFunction(Hooks, char*, __cdecl, GetIPStringFromInAddr, XNADDR* p_InAddr) 24 | { 25 | static char s_IpAddr[64]; 26 | std::memset(s_IpAddr, 0, sizeof(s_IpAddr)); 27 | 28 | // TODO: Figure out what in the hell "type" is stupposed to be 29 | // auto s_Type = *(uint16_t *)((uint8_t *)p_InAddr + 0x12); 30 | // It looks like it reads abEnet[0] + abEnet[1] as uint16_t 31 | sprintf_s(s_IpAddr, sizeof(s_IpAddr), "%hd.%hd.%hd.%hd:%hd (%hd)", 32 | p_InAddr->ina.s_net, p_InAddr->ina.s_host, p_InAddr->ina.s_lh, p_InAddr->ina.s_impno, p_InAddr->wPortOnline, *(uint16_t *)p_InAddr->abEnet); 33 | 34 | return s_IpAddr; 35 | } 36 | 37 | DeclareDetouredFunction(Hooks, bool, __cdecl, XnAddrToInAddr, XNADDR *p_XnAddr, XNKID *p_XnKid, void *p_InAddr) 38 | { 39 | // Fix for XnAddrToInAddr to try checking syslink-menu data for XnAddr->InAddr mapping before consulting XNet 40 | 41 | auto s_MaxMachines = *(uint32_t*)(0x228E6D8); 42 | auto *s_SyslinkData = (uint8_t*)*(uint32_t*)(0x228E6D8 + 0x4); 43 | 44 | for (uint32_t i = 0; i < s_MaxMachines; s_SyslinkData += 0x164F8, i++) 45 | { 46 | auto *s_Entry = s_SyslinkData; 47 | auto s_EntryStatus = *s_Entry; 48 | 49 | if (s_EntryStatus == 0) 50 | continue; 51 | 52 | auto *s_XnKid = s_Entry + 0x9E; 53 | auto *s_XnAddr = s_Entry + 0xAE; 54 | auto *s_IP = s_Entry + 0x170; 55 | auto *s_Port = s_Entry + 0x174; 56 | 57 | if (memcmp(p_XnAddr, s_XnAddr, 0x10) == 0 && memcmp(p_XnKid, s_XnKid, 0x10) == 0) 58 | { 59 | // TODO: map p_InAddr struct: 60 | // 0x0 - 0x10: IP (first 4 bytes for IPv4, 0x10 for IPv6) 61 | // 0x10 - 0x12: Port number 62 | // 0x12 - 0x14: IP length (4 for IPv4, 0x10 for IPv6) 63 | 64 | memset(p_InAddr, 0, 0x14); 65 | memcpy(p_InAddr, s_IP, 4); 66 | memcpy((uint8_t*)p_InAddr + 0x10, s_Port, 2); 67 | 68 | *(uint16_t*)((uint8_t*)p_InAddr + 0x12) = 4; 69 | 70 | return 1; 71 | } 72 | } 73 | 74 | return o_XnAddrToInAddr(p_XnAddr, p_XnKid, p_InAddr); 75 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Networking/Hooks.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct XNADDR; 6 | struct XNKID; 7 | 8 | namespace AnvilEldorado::Game::Networking 9 | { 10 | class Hooks : 11 | public AnvilCommon::Initializable 12 | { 13 | protected: 14 | DeclareFunction(char*, __cdecl, GetIPStringFromInAddr, XNADDR* p_InAddr); 15 | 16 | DeclareFunction(bool, __cdecl, XnAddrToInAddr, XNADDR *p_XnAddr, XNKID *p_XnKid, void *p_InAddr); 17 | public: 18 | virtual bool Init(); 19 | }; 20 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Networking/NetworkingImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "NetworkingImpl.hpp" 2 | #include "Hooks.hpp" 3 | 4 | using namespace AnvilEldorado::Game::Networking; 5 | 6 | bool NetworkingImpl::Init() 7 | { 8 | m_Hooks = std::make_shared(); 9 | if (!m_Hooks->Init()) 10 | return false; 11 | 12 | return true; 13 | } 14 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Networking/NetworkingImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace AnvilEldorado::Game::Networking 6 | { 7 | class NetworkingImpl : 8 | public AnvilCommon::Initializable 9 | { 10 | private: 11 | std::shared_ptr m_Hooks; 12 | 13 | public: 14 | virtual bool Init(); 15 | }; 16 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Networking/XnAddr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct XNADDR 6 | { 7 | IN_ADDR ina; // IP address (zero if not static/DHCP) 8 | IN_ADDR inaOnline; // Online IP address (zero if not online) 9 | uint16_t wPortOnline; // Online port 10 | uint8_t abEnet[6]; // Ethernet MAC address 11 | uint8_t abOnline[20]; // Online identification 12 | }; 13 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Networking/XnKey.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | typedef struct 5 | { 6 | uint8_t ab[16]; // xbox to xbox key exchange key 7 | } XNKEY; -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Networking/XnKid.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | typedef struct 5 | { 6 | uint8_t ab[8]; // xbox to xbox key identifier 7 | } XNKID; -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/Hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "Hooks.hpp" 2 | #include "PlayerImpl.hpp" 3 | 4 | #include 5 | #include 6 | 7 | using namespace AnvilEldorado::Game::Players; 8 | 9 | bool Hooks::Init() 10 | { 11 | auto s_Base = GetClientInterface()->GetEngine()->ExecutableBase(); 12 | 13 | auto s_Address = s_Base + 0x3B7B70; 14 | HookFunctionOffset(s_Address, SetupPlayerArmor); 15 | 16 | return true; 17 | } 18 | 19 | DeclareDetouredFunction(Hooks, void, __cdecl, SetupPlayerArmor, double a1, __m128 a2) 20 | { 21 | auto s_Player = GetClientInterface()->GetEngine()->GetSubsystem(); 22 | 23 | // This function runs every tick, so only update if necessary 24 | if (!s_Player->NeedsArmorUpdate()) 25 | return; 26 | 27 | // Try to get the UI player biped 28 | auto s_UiPlayerBiped = s_Player->GetPodiumBiped(); 29 | if (s_UiPlayerBiped == Blam::Data::DatumIndex::Null) 30 | return; 31 | 32 | s_Player->CustomizeBiped(s_UiPlayerBiped); 33 | s_Player->SetUpdateArmor(false); 34 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/Hooks.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | 6 | namespace AnvilEldorado::Game::Players 7 | { 8 | class Hooks : 9 | public AnvilCommon::Initializable 10 | { 11 | protected: 12 | 13 | DeclareFunction(void, __cdecl, SetupPlayerArmor, double a1, __m128 a2); 14 | 15 | public: 16 | virtual bool Init(); 17 | }; 18 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/PlayerArmorExtension.cpp: -------------------------------------------------------------------------------- 1 | #include "PlayerArmorExtension.hpp" 2 | #include "PlayerImpl.hpp"; 3 | 4 | #include 5 | #include 6 | 7 | using namespace AnvilEldorado::Game::Players; 8 | 9 | void PlayerArmorExtension::BuildData(int32_t p_PlayerIndex, Blam::Game::Players::PlayerCustomization *p_Out) 10 | { 11 | GetClientInterface()->GetEngine()->GetSubsystem()->BuildCustomization(p_Out); 12 | } 13 | 14 | void PlayerArmorExtension::ApplyData(int32_t p_PlayerIndex, Blam::Game::Players::PlayerProperties *p_Properties, const Blam::Game::Players::PlayerCustomization &p_Data) 15 | { 16 | auto armorSessionData = &p_Properties->Customization; 17 | 18 | armorSessionData->Armor[(int)Blam::Game::Players::PlayerArmor::Helmet] = p_Data.Armor[(int)Blam::Game::Players::PlayerArmor::Helmet]; 19 | armorSessionData->Armor[(int)Blam::Game::Players::PlayerArmor::Chest] = p_Data.Armor[(int)Blam::Game::Players::PlayerArmor::Chest]; 20 | armorSessionData->Armor[(int)Blam::Game::Players::PlayerArmor::Shoulders] = p_Data.Armor[(int)Blam::Game::Players::PlayerArmor::Shoulders]; 21 | armorSessionData->Armor[(int)Blam::Game::Players::PlayerArmor::Arms] = p_Data.Armor[(int)Blam::Game::Players::PlayerArmor::Arms]; 22 | armorSessionData->Armor[(int)Blam::Game::Players::PlayerArmor::Legs] = p_Data.Armor[(int)Blam::Game::Players::PlayerArmor::Legs]; 23 | armorSessionData->Armor[(int)Blam::Game::Players::PlayerArmor::Acc] = p_Data.Armor[(int)Blam::Game::Players::PlayerArmor::Acc]; 24 | armorSessionData->Armor[(int)Blam::Game::Players::PlayerArmor::Pelvis] = p_Data.Armor[(int)Blam::Game::Players::PlayerArmor::Pelvis]; 25 | 26 | memcpy(armorSessionData->Colors, p_Data.Colors, sizeof(p_Data.Colors)); 27 | } 28 | 29 | void PlayerArmorExtension::Serialize(Blam::Data::BitStream *p_Stream, const Blam::Game::Players::PlayerCustomization &p_Data) 30 | { 31 | // Colors 32 | for (int32_t i = 0; i < (int)Blam::Game::Players::PlayerColor::Count; i++) 33 | p_Stream->WriteUnsigned(p_Data.Colors[i], 24); 34 | 35 | // Armor 36 | for (int32_t i = 0; i < (int)Blam::Game::Players::PlayerArmor::Count; i++) 37 | p_Stream->WriteUnsigned(p_Data.Armor[i], 0, UINT8_MAX); 38 | } 39 | 40 | void PlayerArmorExtension::Deserialize(Blam::Data::BitStream *p_Stream, Blam::Game::Players::PlayerCustomization *p_Out) 41 | { 42 | memset(p_Out, 0, sizeof(Blam::Game::Players::PlayerCustomization)); 43 | 44 | // Colors 45 | for (int32_t i = 0; i < (int)Blam::Game::Players::PlayerColor::Count; i++) 46 | p_Out->Colors[i] = p_Stream->ReadUnsigned(24); 47 | 48 | // Armor 49 | for (int32_t i = 0; i < (int)Blam::Game::Players::PlayerArmor::Count; i++) 50 | p_Out->Armor[i] = p_Stream->ReadUnsigned(0, UINT8_MAX); 51 | } 52 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/PlayerArmorExtension.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace AnvilEldorado::Game::Players 5 | { 6 | class PlayerArmorExtension : 7 | public PlayerPropertiesExtension 8 | { 9 | protected: 10 | void BuildData(int32_t playerIndex, Blam::Game::Players::PlayerCustomization *out) override; 11 | void ApplyData(int32_t playerIndex, Blam::Game::Players::PlayerProperties *properties, const Blam::Game::Players::PlayerCustomization &data) override; 12 | void Serialize(Blam::Data::BitStream *stream, const Blam::Game::Players::PlayerCustomization &data) override; 13 | void Deserialize(Blam::Data::BitStream *stream, Blam::Game::Players::PlayerCustomization *out) override; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/PlayerImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace AnvilEldorado::Game::Players 14 | { 15 | class PlayerImpl : 16 | public AnvilCommon::Initializable 17 | { 18 | protected: 19 | std::shared_ptr m_Hooks; 20 | 21 | private: 22 | PlayerPropertiesExtender* m_PlayerPropertiesExtender = new PlayerPropertiesExtender();; 23 | 24 | std::wstring m_UserName; 25 | 26 | bool m_UpdateArmor = false; 27 | 28 | uint32_t m_ArmorPrimaryColor; 29 | uint32_t m_ArmorSecondaryColor; 30 | uint32_t m_ArmorVisorColor; 31 | uint32_t m_ArmorLightsColor; 32 | uint32_t m_ArmorHoloColor; 33 | 34 | std::map m_ArmorHelmetIndices; 35 | Blam::Text::StringID m_ArmorHelmet; 36 | 37 | std::map m_ArmorChestIndices; 38 | Blam::Text::StringID m_ArmorChest; 39 | 40 | std::map m_ArmorShouldersIndices; 41 | Blam::Text::StringID m_ArmorShoulders; 42 | 43 | std::map m_ArmorArmsIndices; 44 | Blam::Text::StringID m_ArmorArms; 45 | 46 | std::map m_ArmorLegsIndices; 47 | Blam::Text::StringID m_ArmorLegs; 48 | 49 | std::map m_ArmorPelvisIndices; 50 | Blam::Text::StringID m_ArmorPelvis; 51 | 52 | std::map m_ArmorAccessoryIndices; 53 | Blam::Text::StringID m_ArmorAccessory; 54 | 55 | std::map m_PodiumWeaponIndices; 56 | Blam::Text::StringID m_PodiumWeapon; 57 | 58 | public: 59 | virtual bool Init(); 60 | 61 | Blam::Data::DataArray &GetPlayers(); 62 | Blam::Data::DatumIndex GetLocalPlayer(const int32_t p_Index); 63 | size_t GetPlayerPropertiesPacketSize(); 64 | 65 | bool LoadArmor(Blam::Tags::Game::MultiplayerGlobals *p_MultiplayerGlobals); 66 | 67 | Blam::Data::DatumIndex GetPodiumBiped() const; 68 | 69 | void BuildCustomization(Blam::Game::Players::PlayerCustomization * p_Customization) const; 70 | void CustomizeBiped(const Blam::Data::DatumIndex &p_BipedIndex); 71 | 72 | std::wstring GetName() const; 73 | void SetName(const std::string &p_UserName); 74 | 75 | bool NeedsArmorUpdate() const; 76 | void SetUpdateArmor(const bool p_UpdateArmor = true); 77 | 78 | uint32_t GetArmorPrimaryColor() const; 79 | void SetArmorPrimaryColor(const uint32_t p_Color); 80 | void SetArmorPrimaryColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 81 | 82 | uint32_t GetArmorSecondaryColor() const; 83 | void SetArmorSecondaryColor(const uint32_t p_Color); 84 | void SetArmorSecondaryColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 85 | 86 | uint32_t GetArmorVisorColor() const; 87 | void SetArmorVisorColor(const uint32_t p_Color); 88 | void SetArmorVisorColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 89 | 90 | uint32_t GetArmorLightsColor() const; 91 | void SetArmorLightsColor(const uint32_t p_Color); 92 | void SetArmorLightsColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 93 | 94 | uint32_t GetArmorHoloColor() const; 95 | void SetArmorHoloColor(const uint32_t p_Color); 96 | void SetArmorHoloColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 97 | 98 | Blam::Text::StringID GetArmorHelmet() const; 99 | void SetArmorHelmet(const Blam::Text::StringID &p_ArmorHelmet); 100 | 101 | Blam::Text::StringID GetArmorChest() const; 102 | void SetArmorChest(const Blam::Text::StringID &p_ArmorChest); 103 | 104 | Blam::Text::StringID GetArmorShoulders() const; 105 | void SetArmorShoulders(const Blam::Text::StringID &p_ArmorShoulders); 106 | 107 | Blam::Text::StringID GetArmorArms() const; 108 | void SetArmorArms(const Blam::Text::StringID &p_ArmorArms); 109 | 110 | Blam::Text::StringID GetArmorLegs() const; 111 | void SetArmorLegs(const Blam::Text::StringID &p_ArmorLegs); 112 | 113 | Blam::Text::StringID GetArmorPelvis() const; 114 | void SetArmorPelvis(const Blam::Text::StringID &p_ArmorPelvis); 115 | 116 | Blam::Text::StringID GetArmorAccessory() const; 117 | void SetArmorAccessory(const Blam::Text::StringID &p_ArmorAccessory); 118 | 119 | Blam::Text::StringID GetPodiumWeapon() const; 120 | void SetPodiumWeapon(const Blam::Text::StringID &p_PodiumWeapon); 121 | }; 122 | 123 | // Packet size constants 124 | extern const size_t PlayerPropertiesPacketHeaderSize; 125 | extern const size_t PlayerPropertiesSize; 126 | extern const size_t PlayerPropertiesPacketFooterSize; 127 | } 128 | -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/PlayerPropertiesExtender.cpp: -------------------------------------------------------------------------------- 1 | #include "PlayerPropertiesExtender.hpp" 2 | 3 | using namespace AnvilEldorado::Game::Players; 4 | 5 | void PlayerPropertiesExtender::Add(std::shared_ptr extension) 6 | { 7 | extensions.push_back(extension); 8 | } 9 | 10 | size_t PlayerPropertiesExtender::GetTotalSize() 11 | { 12 | size_t result = 0; 13 | for (auto it = extensions.begin(); it != extensions.end(); ++it) 14 | result += (*it)->GetDataSize(); 15 | return result; 16 | } 17 | 18 | void PlayerPropertiesExtender::BuildData(int32_t playerIndex, void *out) 19 | { 20 | // Write all of the data structures in order 21 | uint8_t *ptr = static_cast(out); 22 | for (auto it = extensions.begin(); it != extensions.end(); ++it) 23 | { 24 | (*it)->BuildData(playerIndex, ptr); 25 | ptr += (*it)->GetDataSize(); 26 | } 27 | } 28 | 29 | void PlayerPropertiesExtender::ApplyData(int32_t playerIndex, Blam::Game::Players::PlayerProperties *properties, const void *data) 30 | { 31 | // Apply all of the data structures in order 32 | const uint8_t *ptr = static_cast(data); 33 | for (auto it = extensions.begin(); it != extensions.end(); ++it) 34 | { 35 | (*it)->ApplyData(playerIndex, properties, ptr); 36 | ptr += (*it)->GetDataSize(); 37 | } 38 | } 39 | 40 | void PlayerPropertiesExtender::SerializeData(Blam::Data::BitStream *stream, const void *data) 41 | { 42 | // Serialize all of the structures in order 43 | const uint8_t *ptr = static_cast(data); 44 | for (auto it = extensions.begin(); it != extensions.end(); ++it) 45 | { 46 | (*it)->Serialize(stream, ptr); 47 | ptr += (*it)->GetDataSize(); 48 | } 49 | } 50 | 51 | void PlayerPropertiesExtender::DeserializeData(Blam::Data::BitStream *stream, void *out) 52 | { 53 | // Deserialize all of the structures in order 54 | uint8_t *ptr = static_cast(out); 55 | for (auto it = extensions.begin(); it != extensions.end(); ++it) 56 | { 57 | (*it)->Deserialize(stream, ptr); 58 | ptr += (*it)->GetDataSize(); 59 | } 60 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/PlayerPropertiesExtender.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PlayerPropertiesExtensionBase.hpp" 3 | #include 4 | #include 5 | 6 | namespace AnvilEldorado::Game::Players 7 | { 8 | // Singleton object which lets the player-properties packet be extended with custom data 9 | // TODO: Make this more generic and not so specific to player-properties 10 | class PlayerPropertiesExtender 11 | { 12 | public: 13 | // Adds an extension to the player-properties packet. 14 | void Add(std::shared_ptr extension); 15 | 16 | // Gets the total size of the player-properties extension data. 17 | size_t GetTotalSize(); 18 | 19 | // Writes all extension data out to a player-properties structure. 20 | void BuildData(int32_t playerIndex, void *out); 21 | 22 | // Applies all extension data in a player-properties structure. 23 | void ApplyData(int32_t playerIndex, Blam::Game::Players::PlayerProperties *properties, const void *data); 24 | 25 | // Serializes all extension data in a player-properties structure. 26 | void SerializeData(Blam::Data::BitStream *stream, const void *data); 27 | 28 | // Deserializes all extension data in a player-properties structure. 29 | void DeserializeData(Blam::Data::BitStream *stream, void *out); 30 | 31 | private: 32 | std::vector> extensions; 33 | }; 34 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/PlayerPropertiesExtension.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PlayerPropertiesExtensionBase.hpp" 3 | 4 | namespace AnvilEldorado::Game::Players 5 | { 6 | // Helper class which adds type safety to PlayerPropertiesExtensionBase. 7 | template 8 | class PlayerPropertiesExtension : public PlayerPropertiesExtensionBase 9 | { 10 | protected: 11 | // Builds extension data for a player. 12 | virtual void BuildData(int32_t playerIndex, TData *out) = 0; 13 | 14 | // Applies extension data to a player. 15 | virtual void ApplyData(int32_t playerIndex, Blam::Game::Players::PlayerProperties *properties, const TData &data) = 0; 16 | 17 | // Serializes the extension data to be sent across the network. 18 | virtual void Serialize(Blam::Data::BitStream *stream, const TData &data) = 0; 19 | 20 | // Deserializes extension data that was received from the network. 21 | virtual void Deserialize(Blam::Data::BitStream *stream, TData *out) = 0; 22 | 23 | public: 24 | 25 | void BuildData(int32_t playerIndex, void *out) override 26 | { 27 | BuildData(playerIndex, static_cast(out)); 28 | } 29 | 30 | size_t GetDataSize() const override 31 | { 32 | return sizeof(TData); 33 | } 34 | 35 | void ApplyData(int32_t playerIndex, Blam::Game::Players::PlayerProperties *properties, const void *data) override 36 | { 37 | ApplyData(playerIndex, properties, *static_cast(data)); 38 | } 39 | 40 | void Serialize(Blam::Data::BitStream *stream, const void *data) override 41 | { 42 | Serialize(stream, *static_cast(data)); 43 | } 44 | 45 | void Deserialize(Blam::Data::BitStream *stream, void *out) override 46 | { 47 | Deserialize(stream, static_cast(out)); 48 | } 49 | }; 50 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/Players/PlayerPropertiesExtensionBase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace AnvilEldorado::Game::Players 6 | { 7 | // Base class for a class which adds data to player properties. 8 | class PlayerPropertiesExtensionBase 9 | { 10 | public: 11 | virtual ~PlayerPropertiesExtensionBase() {} 12 | 13 | // Builds extension data for a player. 14 | virtual void BuildData(int32_t playerIndex, void *out) = 0; 15 | 16 | // Gets the size of the extension data. 17 | virtual size_t GetDataSize() const = 0; 18 | 19 | // Applies extension data to a player. 20 | virtual void ApplyData(int32_t playerIndex, Blam::Game::Players::PlayerProperties *properties, const void *data) = 0; 21 | 22 | // Serializes the extension data to be sent across the network. 23 | virtual void Serialize(Blam::Data::BitStream *stream, const void *data) = 0; 24 | 25 | // Deserializes extension data that was received from the network. 26 | virtual void Deserialize(Blam::Data::BitStream *stream, void *out) = 0; 27 | }; 28 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/UI/Hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "Hooks.hpp" 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | using namespace AnvilEldorado::Game::UI; 10 | 11 | bool Hooks::Init() 12 | { 13 | auto s_Base = GetClientInterface()->GetEngine()->ExecutableBase(); 14 | 15 | auto s_Address = s_Base + 0x0011E040; 16 | HookFunctionOffset(s_Address, LocalizeString); 17 | 18 | s_Address = s_Base + 0x006DF6E0; 19 | HookFunctionOffset(s_Address, MainMenuUpdate); 20 | 21 | return true; 22 | } 23 | 24 | DeclareDetouredFunction(Hooks, bool, __cdecl, LocalizeString, int p_TagIndex, Blam::Text::StringID p_StringId, wchar_t* p_Output) 25 | { 26 | const static size_t MaxStringLength = 0x400; 27 | 28 | if (p_StringId == 0x1010A /* start_new_campaign */) 29 | { 30 | #if _DEBUG 31 | swprintf_s(p_Output, MaxStringLength, L"Anvil: Online - Dev Build - %d", ANVIL_BUILD); 32 | #else 33 | swprintf_s(p_Output, MaxStringLength, L"Anvil: Online - %d", ANVIL_BUILD); 34 | #endif 35 | return true; 36 | } 37 | 38 | return o_LocalizeString(p_TagIndex, p_StringId, p_Output); 39 | } 40 | 41 | DeclareDetouredFunction(Hooks, void, __fastcall, MainMenuUpdate, int thiz, void* unused, Blam::Text::StringID p_MenuName) 42 | { 43 | //TODO: Struct this out 44 | auto s_ShouldUpdate = *(uint32_t *)((uint8_t*)thiz + 0x10) >= 0x1E; 45 | 46 | o_MainMenuUpdate(thiz, unused, p_MenuName); 47 | 48 | if (s_ShouldUpdate) 49 | { 50 | void *s_UIData = UIImpl::ShowDialog(p_MenuName, 0xFF, 4, 0x1000D); 51 | 52 | if (s_UIData != nullptr) 53 | *(uint32_t*)((char*)s_UIData + 0x18) = 1; 54 | } 55 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/UI/Hooks.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace AnvilEldorado::Game::UI 9 | { 10 | class Hooks : 11 | public AnvilCommon::Initializable 12 | { 13 | protected: 14 | DeclareFunction(bool, __cdecl, LocalizeString, int p_TagIndex, Blam::Text::StringID p_StringId, wchar_t* p_Output); 15 | 16 | DeclareFunction(void, __fastcall, MainMenuUpdate, int that, void* unused, Blam::Text::StringID p_MenuName); 17 | 18 | public: 19 | virtual bool Init(); 20 | }; 21 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/UI/UIImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "UIImpl.hpp" 2 | #include "Hooks.hpp" 3 | 4 | using namespace AnvilEldorado::Game::UI; 5 | 6 | bool UIImpl::Init() 7 | { 8 | m_Hooks = std::make_shared(); 9 | if (!m_Hooks->Init()) 10 | return false; 11 | 12 | return true; 13 | } 14 | 15 | const auto UI_Alloc = reinterpret_cast(0xAB4ED0); 16 | const auto UI_OpenDialogById = reinterpret_cast(0xA92780); 17 | const auto UI_PostMessage = reinterpret_cast(0xA93450); 18 | 19 | void* UIImpl::ShowDialog(const Blam::Text::StringID &p_DialogID, const int32_t p_Arg1, const int32_t p_Flags, const Blam::Text::StringID &p_ParentID) 20 | { 21 | // TODO: Fix 22 | //WriteLog("Showing ui dialog '%s'...", Blam::Cache::StringIDCache::Instance()->GetString(p_DialogID)); 23 | 24 | auto *s_UIData = UI_Alloc(0x40); 25 | 26 | if (!s_UIData) 27 | return nullptr; 28 | 29 | UI_OpenDialogById(s_UIData, p_DialogID, p_Arg1, p_Flags, p_ParentID); 30 | UI_PostMessage(s_UIData); 31 | 32 | return s_UIData; 33 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Game/UI/UIImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace AnvilEldorado::Game::UI 9 | { 10 | class UIImpl : 11 | public AnvilCommon::Initializable 12 | { 13 | protected: 14 | std::shared_ptr m_Hooks; 15 | 16 | public: 17 | virtual bool Init(); 18 | 19 | static void* ShowDialog(const Blam::Text::StringID &p_DialogID, const int32_t p_Arg1, const int32_t p_Flags, const Blam::Text::StringID &p_ParentID); 20 | }; 21 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/GameImpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "Blam\Game\Variants.hpp" 10 | 11 | namespace AnvilEldorado 12 | { 13 | enum class GameLocale : int8_t 14 | { 15 | English, // en-US 16 | Japanese, // jp-JP 17 | German, // de-DE 18 | French, // fr-FR 19 | Spanish, // es-ES 20 | Mexican, // es-MX 21 | Italian, // it-IT 22 | Korean, // ko-KR 23 | ChineseTraditional, // zh-TW 24 | ChineseSimplified, // zh-CN 25 | Portuguese, // pt-PT 26 | Russian // ru-RU 27 | }; 28 | 29 | enum class GameLobbyType : int32_t 30 | { 31 | None, 32 | Campaign, 33 | CustomGame, 34 | Forge 35 | }; 36 | 37 | class GameImpl : 38 | public AnvilCommon::Initializable 39 | { 40 | public: 41 | bool Init() override; 42 | 43 | GameLocale GetGameLocale() const; 44 | bool SetGameLocale(const GameLocale &p_Locale); 45 | 46 | void Shutdown(); 47 | 48 | bool StartGame(); 49 | bool EndGame(); 50 | 51 | int32_t GetMapID(const std::string &p_MapName); 52 | 53 | bool LoadMap(const std::string &p_MapName); 54 | bool OnMapLoaded(void *p_Data); 55 | 56 | bool LoadMapVariant(std::ifstream &p_File, uint8_t *out); 57 | bool LoadDefaultMapVariant(const std::string &p_MapPath, uint8_t *out); 58 | void SaveMapVariantToPreferences(const uint8_t *p_Data); 59 | 60 | GameLobbyType GetLobbyType() const; 61 | 62 | const std::vector &GetMaps() const; 63 | const std::vector &GetMapVariants() const; 64 | 65 | private: 66 | GameLocale m_Locale; 67 | std::vector m_Maps; 68 | std::vector m_MapVariants; 69 | }; 70 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Globals.cpp: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | 4 | #include 5 | 6 | #include "BuildInfo.hpp" 7 | #include "Globals.hpp" 8 | 9 | std::string AnvilCommon::g_BuildInfo = "AnvilEldorado Client - " + std::string(__DATE__) + " - Build: " + std::to_string(ANVIL_BUILD); 10 | 11 | void *AnvilCommon::Internal_GetThreadStorage(const size_t p_Offset) 12 | { 13 | static void *s_ThreadStorage = nullptr; 14 | 15 | if (!s_ThreadStorage) 16 | { 17 | _asm 18 | { 19 | mov eax, dword ptr fs : [2Ch] 20 | mov eax, dword ptr ds : [eax] 21 | mov s_ThreadStorage, eax 22 | } 23 | } 24 | 25 | return (uint8_t *)s_ThreadStorage + p_Offset; 26 | } 27 | 28 | void *AnvilCommon::Internal_GetModuleStorage(const size_t p_Offset) 29 | { 30 | static void *s_ModuleStorage = nullptr; 31 | 32 | if (s_ModuleStorage == nullptr) 33 | { 34 | auto s_Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId()); 35 | 36 | if (s_Snapshot == INVALID_HANDLE_VALUE) 37 | return nullptr; 38 | 39 | MODULEENTRY32 s_ModuleEntry; 40 | s_ModuleEntry.dwSize = sizeof(MODULEENTRY32); 41 | 42 | auto s_Module = Module32First(s_Snapshot, &s_ModuleEntry); 43 | 44 | CloseHandle(s_Snapshot); 45 | 46 | s_ModuleStorage = (s_Module != 0) ? (void*)s_ModuleEntry.modBaseAddr : nullptr; 47 | } 48 | 49 | return s_ModuleStorage; 50 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Graphics.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Blam\Math\RealColorRGB.hpp" 5 | 6 | namespace AnvilEldorado 7 | { 8 | struct GraphicsGlobals 9 | { 10 | int32_t Override; // bool 11 | float Saturation; 12 | Blam::Math::RealColorRGB Hue; 13 | }; 14 | 15 | struct BloomGlobals 16 | { 17 | int32_t Enabled; // bool 18 | float Intensity; 19 | }; 20 | 21 | struct DepthOfFieldGlobals 22 | { 23 | int32_t Enabled; // bool 24 | float Intensity; 25 | }; 26 | 27 | struct CinematicGlobals 28 | { 29 | int32_t Unknown0; 30 | int32_t LetterboxEnabled; 31 | }; 32 | 33 | class Graphics : 34 | public AnvilCommon::Initializable 35 | { 36 | public: 37 | static GraphicsGlobals *GetGraphicsGlobals(); 38 | static BloomGlobals *GetBloomGlobals(); 39 | static DepthOfFieldGlobals *GetDepthOfFieldGlobals(); 40 | static CinematicGlobals *GetCinematicGlobals(); 41 | 42 | bool Init() override; 43 | 44 | float GetRedHue() const; 45 | void SetRedHue(const float p_RedHue); 46 | 47 | float GetGreenHue() const; 48 | void SetGreenHue(const float p_GreenHue); 49 | 50 | float GetBlueHue() const; 51 | void SetBlueHue(const float p_BlueHue); 52 | 53 | Blam::Math::RealColorRGB GetHue() const; 54 | void SetHue(const Blam::Math::RealColorRGB &p_Hue); 55 | 56 | float GetSaturation() const; 57 | void SetSaturation(const float p_Saturation); 58 | 59 | float GetBloomIntensity() const; 60 | void SetBloomIntensity(const float p_Intensity); 61 | 62 | float GetDepthOfFieldIntensity() const; 63 | void SetDepthOfFieldIntensity(const float p_Intensity); 64 | 65 | bool IsLetterboxEnabled() const; 66 | void SetLetterboxEnabled(const bool p_Enabled = true); 67 | }; 68 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Hooking/Hooking.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #define DeclareFunction(returnType, callingMethod, name, ...) \ 6 | typedef returnType (callingMethod* name ## _t)(__VA_ARGS__); \ 7 | static name ## _t o_ ## name; \ 8 | static returnType callingMethod hk_ ## name(__VA_ARGS__); 9 | 10 | #define DeclareDetouredFunction(nameSpace, returnType, callingMethod, name, ...) \ 11 | nameSpace::name ## _t nameSpace::o_ ## name = (nameSpace::name ## _t)nullptr; \ 12 | returnType callingMethod nameSpace::hk_ ## name(__VA_ARGS__) 13 | 14 | #define HookFunctionOffset(offset, name) \ 15 | if (MH_CreateHook(offset, &hk_ ## name, reinterpret_cast(&o_ ## name)) != MH_OK) \ 16 | { WriteLog("Could not hook %s.", #name); } else { WriteLog("%s hooked.", #name); } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Input.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Blam::Input 14 | { 15 | enum ControllerButton : uint8_t; 16 | enum GameAction : uint8_t; 17 | } 18 | 19 | namespace AnvilEldorado 20 | { 21 | // Base class for objects which override game input. 22 | // While a context is active, all game input is blocked. 23 | class InputContext 24 | { 25 | public: 26 | virtual ~InputContext() { } 27 | 28 | // Called when the input context is made active. 29 | virtual void Activated() = 0; 30 | 31 | // Called when the input context is deactivated. 32 | virtual void Deactivated() = 0; 33 | 34 | // Called on the active context each time the game processes input, 35 | // overriding the default input processing routine. If this returns 36 | // false, the input context will be deactivated. 37 | // 38 | // The difference between this and UiInputTick() is that this 39 | // cannot call Blam::Input::ReadKeyEvent() because Windows messages 40 | // won't have been pumped yet. However, this happens earlier on in 41 | // the engine update cycle. 42 | virtual bool GameInputTick() = 0; 43 | 44 | // Called on the active context each time Windows messages are 45 | // pumped. If this returns false, the input context will be 46 | // deactivated. 47 | virtual bool UiInputTick() = 0; 48 | }; 49 | 50 | class Input : public AnvilCommon::Initializable 51 | { 52 | public: 53 | bool Init() override; 54 | 55 | std::stack> &GetContextStack(); 56 | 57 | void PushContext(std::shared_ptr p_Context); 58 | void PopContext(); 59 | 60 | bool IsContextDone() const; 61 | void SetContextDone(const bool p_Done = true); 62 | 63 | void SetInputTypeBlocked(const Blam::Input::InputType &p_Type, const bool p_Blocked = true); 64 | 65 | typedef std::function DefaultInputHandler; 66 | 67 | std::vector &GetDefaultHandlers(); 68 | 69 | // Registers a function to be called when the default input handler is 70 | // ticked. 71 | void RegisterDefaultInputHandler(DefaultInputHandler p_Handler); 72 | 73 | // Sets what controls can be configured in the keyboard settings menu. 74 | void SetKeyboardSettingsMenu( 75 | const std::vector &infantrySettings, 76 | const std::vector &vehicleSettings); 77 | 78 | bool RawInputEnabled() const; 79 | void SetRawInputEnabled(const bool p_Enabled = true); 80 | 81 | int32_t GetControllerPort() const; 82 | void SetControllerPort(const int32_t p_Port); 83 | 84 | float GetControllerHorizontalSensitivity() const; 85 | void SetControllerHorizontalSensitivity(const float p_Sensitivity); 86 | 87 | float GetControllerVerticalSensitivity() const; 88 | void SetControllerVerticalSensitivity(const float p_Sensitivity); 89 | 90 | Blam::Input::BindingsTable &GetBindings(); 91 | void LoadDefaultBindings(); 92 | void UpdateBindings(); 93 | void CopyBinding(const Blam::Input::GameAction &p_SourceAction, const Blam::Input::GameAction &p_DestAction); 94 | 95 | bool BindControllerAction(const Blam::Input::GameAction &p_GameAction, const Blam::Input::ControllerButton &p_ControllerButton); 96 | bool BindKeyboardAction(const Blam::Input::GameAction &p_GameAction, const Blam::Input::KeyCode &p_PrimaryKey, const Blam::Input::KeyCode &p_SecondaryKey = Blam::Input::eKeyCode_None); 97 | bool BindMouseAction(const Blam::Input::GameAction &p_GameAction, const Blam::Input::MouseButton &p_PrimaryButton, const Blam::Input::MouseButton &p_SecondaryButton = Blam::Input::eMouseButton_None); 98 | 99 | private: 100 | bool m_RawInputEnabled; 101 | int32_t m_ControllerPort; 102 | Blam::Input::BindingsTable m_Bindings; 103 | std::vector m_Settings; 104 | std::stack> m_ContextStack; 105 | std::vector m_DefaultHandlers; 106 | bool m_ContextDone = false; 107 | bool m_BlockStates[Blam::Input::eInputType_Count]; 108 | Blam::Input::InputType m_ActionInputTypes[Blam::Input::eGameAction_KeyboardMouseCount]; 109 | }; 110 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Network.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | namespace AnvilEldorado 8 | { 9 | class Network : 10 | public AnvilCommon::Initializable 11 | { 12 | public: 13 | bool Init() override; 14 | 15 | bool StartServer(); 16 | bool StopServer(); 17 | 18 | std::string GetServerName() const; 19 | void SetServerName(const std::string &p_ServerName); 20 | 21 | std::string GetServerMessage() const; 22 | void SetServerMessage(const std::string &p_ServerMessage); 23 | 24 | std::string GetServerPassword() const; 25 | void SetServerPassword(const std::string &p_ServerPassword); 26 | 27 | uint32_t GetServerCountdown() const; 28 | void SetServerCountdown(const uint32_t p_ServerCountdown); 29 | 30 | uint32_t GetServerMaximumPlayers() const; 31 | void SetServerMaximumPlayers(const uint32_t p_ServerMaximumPlayers); 32 | 33 | uint32_t GetServerPort() const; 34 | void SetServerPort(const uint32_t p_Port); 35 | 36 | uint32_t GetServerGamePort() const; 37 | void SetServerGamePort(const uint32_t p_ServerGamePort); 38 | 39 | void OnPongReceived(const Blam::Network::NetworkAddress &p_From, const Blam::Network::PongPacket &p_Pong, uint32_t p_Latency); 40 | void OnLifeCycleStateChanged(const Blam::Network::LifeCycleState &p_NewState); 41 | 42 | private: 43 | SOCKET m_ServerSocket; 44 | bool m_ServerSocketOpen = false; 45 | 46 | std::string m_ServerName = "Halo: Online"; 47 | std::string m_ServerMessage = ""; 48 | std::string m_ServerPassword = ""; 49 | uint32_t m_ServerCountdown = 5; 50 | uint32_t m_ServerMaximumPlayers = 16; 51 | uint32_t m_ServerPort = 11775; 52 | uint32_t m_ServerGamePort = 0; 53 | bool m_ServerShouldAnnounce; 54 | }; 55 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/Player.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | namespace AnvilEldorado 13 | { 14 | class PlayerArmorExtension : 15 | public Game::Players::PlayerPropertiesExtension 16 | { 17 | protected: 18 | void BuildData(int32_t playerIndex, Blam::Game::Players::PlayerCustomization *out) override; 19 | void ApplyData(int32_t playerIndex, Blam::Game::Players::PlayerProperties *properties, const Blam::Game::Players::PlayerCustomization &data) override; 20 | void Serialize(Blam::Data::BitStream *stream, const Blam::Game::Players::PlayerCustomization &data) override; 21 | void Deserialize(Blam::Data::BitStream *stream, Blam::Game::Players::PlayerCustomization *out) override; 22 | }; 23 | 24 | class Player : 25 | public AnvilCommon::Initializable 26 | { 27 | public: 28 | bool Init() override; 29 | 30 | bool LoadArmor(Blam::Tags::Game::MultiplayerGlobals *p_MultiplayerGlobals); 31 | bool LoadPodiumWeapons(Blam::Tags::Game::MultiplayerGlobals *p_MultiplayerGlobals); 32 | 33 | Blam::Data::DatumIndex GetPodiumBiped() const; 34 | 35 | void BuildCustomization(Blam::Game::Players::PlayerCustomization *p_Customization) const; 36 | void CustomizeBiped(const Blam::Data::DatumIndex &p_BipedIndex); 37 | 38 | std::wstring GetUserName() const; 39 | void SetUserName(const std::string &p_UserName); 40 | 41 | bool NeedsArmorUpdate() const; 42 | void SetUpdateArmor(const bool p_UpdateArmor = true); 43 | 44 | uint32_t GetArmorPrimaryColor() const; 45 | void SetArmorPrimaryColor(const uint32_t p_Color); 46 | void SetArmorPrimaryColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 47 | 48 | uint32_t GetArmorSecondaryColor() const; 49 | void SetArmorSecondaryColor(const uint32_t p_Color); 50 | void SetArmorSecondaryColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 51 | 52 | uint32_t GetArmorVisorColor() const; 53 | void SetArmorVisorColor(const uint32_t p_Color); 54 | void SetArmorVisorColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 55 | 56 | uint32_t GetArmorLightsColor() const; 57 | void SetArmorLightsColor(const uint32_t p_Color); 58 | void SetArmorLightsColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 59 | 60 | uint32_t GetArmorHoloColor() const; 61 | void SetArmorHoloColor(const uint32_t p_Color); 62 | void SetArmorHoloColor(const uint8_t p_Red, const uint8_t p_Green, const uint8_t p_Blue); 63 | 64 | std::string GetArmorHelmet() const; 65 | void SetArmorHelmet(const std::string &p_ArmorHelmet); 66 | 67 | std::string GetArmorChest() const; 68 | void SetArmorChest(const std::string &p_ArmorChest); 69 | 70 | std::string GetArmorShoulders() const; 71 | void SetArmorShoulders(const std::string &p_ArmorShoulders); 72 | 73 | std::string GetArmorArms() const; 74 | void SetArmorArms(const std::string &p_ArmorArms); 75 | 76 | std::string GetArmorLegs() const; 77 | void SetArmorLegs(const std::string &p_ArmorLegs); 78 | 79 | std::string GetArmorPelvis() const; 80 | void SetArmorPelvis(const std::string &p_ArmorPelvis); 81 | 82 | std::string GetArmorAccessory() const; 83 | void SetArmorAccessory(const std::string &p_ArmorAccessory); 84 | 85 | std::string GetPodiumWeapon() const; 86 | void SetPodiumWeapon(const std::string &p_PodiumWeapon); 87 | 88 | private: 89 | std::wstring m_UserName; 90 | 91 | bool m_UpdateArmor = false; 92 | 93 | uint32_t m_ArmorPrimaryColor; 94 | uint32_t m_ArmorSecondaryColor; 95 | uint32_t m_ArmorVisorColor; 96 | uint32_t m_ArmorLightsColor; 97 | uint32_t m_ArmorHoloColor; 98 | 99 | std::map m_ArmorHelmetIndices; 100 | std::string m_ArmorHelmet; 101 | 102 | std::map m_ArmorChestIndices; 103 | std::string m_ArmorChest; 104 | 105 | std::map m_ArmorShouldersIndices; 106 | std::string m_ArmorShoulders; 107 | 108 | std::map m_ArmorArmsIndices; 109 | std::string m_ArmorArms; 110 | 111 | std::map m_ArmorLegsIndices; 112 | std::string m_ArmorLegs; 113 | 114 | std::map m_ArmorPelvisIndices; 115 | std::string m_ArmorPelvis; 116 | 117 | std::map m_ArmorAccessoryIndices; 118 | std::string m_ArmorAccessory; 119 | 120 | std::map m_PodiumWeaponIndices; 121 | std::string m_PodiumWeapon; 122 | }; 123 | } -------------------------------------------------------------------------------- /AnvilEldorado/Source/UserInterface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include "Blam\Text\StringID.hpp" 9 | 10 | namespace AnvilEldorado 11 | { 12 | class UserInterface : 13 | public AnvilCommon::Initializable 14 | { 15 | public: 16 | bool Init() override; 17 | 18 | typedef std::function CreateWindowCallback; 19 | HWND CreateGameWindow(); 20 | 21 | bool ShouldScaleInterface() const; 22 | void SetScaleInterface(const bool p_ScaleInterface = true); 23 | 24 | void ApplyResolution(); 25 | 26 | void *ShowDialog(const Blam::Text::StringID &p_DialogID, const int32_t p_Arg1 = 0, const int32_t p_Flags = 4, const Blam::Text::StringID &p_ParentID = Blam::Text::StringID::Null); 27 | 28 | private: 29 | std::vector m_CreateWindowCallbacks; 30 | 31 | bool m_ScaleInterface = true; 32 | 33 | int m_HudResolutionWidth = 0; 34 | int m_HudResolutionHeight = 0; 35 | float m_HudResolutionScaleX = 0; 36 | float m_HudResolutionScaleY = 0; 37 | float m_HudMotionSensorOffsetX = 0; 38 | float m_HudBottomVisorOffsetY = 0; 39 | bool m_FirstResolutionChange = true; 40 | }; 41 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Anvil Online 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AnvilClient 2 | The main C++ module to take control and expand the running game engine. 3 | --------------------------------------------------------------------------------