From 8f6d02a0b89d1081b54b5c6cfbc0d222be0fcf04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Krupi=C5=84ski?= Date: Tue, 24 Sep 2024 19:30:58 +0200 Subject: [PATCH] Optimize size of GameDependencies initialization code and const data --- Source/CS2/Classes/Entities/CBaseAnimGraph.h | 1 - Source/CS2/Classes/Entities/C_CSPlayerPawn.h | 2 - .../CS2/Classes/Entities/GrenadeProjectiles.h | 5 -- Source/CS2/Classes/Entities/WeaponEntities.h | 38 --------- Source/CS2/Constants/EntityTypeNames.h | 56 +++++++++++++ .../CS2/Constants/StylePropertySymbolNames.h | 26 ++++++ Source/CS2/Constants/StylePropertyTypeNames.h | 27 +++++++ Source/CS2/Panorama/StyleProperties.h | 44 ----------- .../StylePropertiesSymbolsAndVMTs.h | 41 +++------- Source/GameDependencies/EntitiesVMTs.h | 79 +------------------ Source/Osiris.vcxproj | 4 + Source/Osiris.vcxproj.filters | 12 +++ Source/Utils/TypedStaticStringPool.h | 47 +++++++++++ 13 files changed, 189 insertions(+), 193 deletions(-) create mode 100644 Source/CS2/Constants/EntityTypeNames.h create mode 100644 Source/CS2/Constants/StylePropertySymbolNames.h create mode 100644 Source/CS2/Constants/StylePropertyTypeNames.h create mode 100644 Source/Utils/TypedStaticStringPool.h diff --git a/Source/CS2/Classes/Entities/CBaseAnimGraph.h b/Source/CS2/Classes/Entities/CBaseAnimGraph.h index 467eafbc0b5..088582c7a04 100644 --- a/Source/CS2/Classes/Entities/CBaseAnimGraph.h +++ b/Source/CS2/Classes/Entities/CBaseAnimGraph.h @@ -7,7 +7,6 @@ namespace cs2 { struct CBaseAnimGraph : C_BaseEntity { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCBaseAnimGraph@@", "14CBaseAnimGraph")}; }; } diff --git a/Source/CS2/Classes/Entities/C_CSPlayerPawn.h b/Source/CS2/Classes/Entities/C_CSPlayerPawn.h index ba718f8a055..79754dd6178 100644 --- a/Source/CS2/Classes/Entities/C_CSPlayerPawn.h +++ b/Source/CS2/Classes/Entities/C_CSPlayerPawn.h @@ -12,8 +12,6 @@ struct CCSPlayer_HostageServices; struct CCSPlayer_WeaponServices; struct C_CSPlayerPawn : C_BaseEntity { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_CSPlayerPawn@@", "14C_CSPlayerPawn")}; - using m_bGunGameImmunity = bool; using m_pWeaponServices = CCSPlayer_WeaponServices*; using m_hController = CEntityHandle; diff --git a/Source/CS2/Classes/Entities/GrenadeProjectiles.h b/Source/CS2/Classes/Entities/GrenadeProjectiles.h index e282537a517..69c998a5094 100644 --- a/Source/CS2/Classes/Entities/GrenadeProjectiles.h +++ b/Source/CS2/Classes/Entities/GrenadeProjectiles.h @@ -7,21 +7,16 @@ namespace cs2 { struct C_HEGrenadeProjectile : C_BaseCSGrenadeProjectile { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_HEGrenadeProjectile@@", "21C_HEGrenadeProjectile")}; }; struct C_SmokeGrenadeProjectile : C_BaseCSGrenadeProjectile { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_SmokeGrenadeProjectile@@", "24C_SmokeGrenadeProjectile")}; - using m_bDidSmokeEffect = bool; }; struct C_MolotovProjectile : C_BaseCSGrenadeProjectile { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_MolotovProjectile@@", "19C_MolotovProjectile")}; }; struct C_FlashbangProjectile : C_BaseCSGrenadeProjectile { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_FlashbangProjectile@@", "21C_FlashbangProjectile")}; }; } diff --git a/Source/CS2/Classes/Entities/WeaponEntities.h b/Source/CS2/Classes/Entities/WeaponEntities.h index dd0732924df..b7caa6a0f57 100644 --- a/Source/CS2/Classes/Entities/WeaponEntities.h +++ b/Source/CS2/Classes/Entities/WeaponEntities.h @@ -7,155 +7,117 @@ namespace cs2 { struct C_WeaponGlock : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponGlock@@", "13C_WeaponGlock")}; }; struct C_WeaponHKP2000 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponHKP2000@@", "15C_WeaponHKP2000")}; }; struct C_WeaponElite : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponElite@@", "13C_WeaponElite")}; }; struct C_WeaponP250 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponP250@@", "12C_WeaponP250")}; }; struct C_WeaponTec9 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponTec9@@", "12C_WeaponTec9")}; }; struct C_WeaponFiveSeven : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponFiveSeven@@", "17C_WeaponFiveSeven")}; }; struct C_DEagle : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_DEagle@@", "8C_DEagle")}; }; struct C_WeaponMAC10 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponMAC10@@", "13C_WeaponMAC10")}; }; struct C_WeaponMP7 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponMP7@@", "11C_WeaponMP7")}; }; struct C_WeaponMP9 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponMP9@@", "11C_WeaponMP9")}; }; struct C_WeaponUMP45 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponUMP45@@", "13C_WeaponUMP45")}; }; struct C_WeaponP90 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponP90@@", "11C_WeaponP90")}; }; struct C_WeaponBizon : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponBizon@@", "13C_WeaponBizon")}; }; struct C_WeaponMag7 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponMag7@@", "12C_WeaponMag7")}; }; struct C_WeaponSawedoff : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponSawedoff@@", "16C_WeaponSawedoff")}; }; struct C_WeaponXM1014 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponXM1014@@", "14C_WeaponXM1014")}; }; struct C_WeaponNOVA : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponNOVA@@", "12C_WeaponNOVA")}; }; struct C_WeaponM249 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponM249@@", "12C_WeaponM249")}; }; struct C_WeaponNegev : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponNegev@@", "13C_WeaponNegev")}; }; struct C_WeaponGalilAR : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponGalilAR@@", "15C_WeaponGalilAR")}; }; struct C_WeaponFamas : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponFamas@@", "13C_WeaponFamas")}; }; struct C_AK47 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_AK47@@", "6C_AK47")}; }; struct C_WeaponM4A1 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponM4A1@@", "12C_WeaponM4A1")}; }; struct C_WeaponSG556 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponSG556@@", "13C_WeaponSG556")}; }; struct C_WeaponAug : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponAug@@", "11C_WeaponAug")}; }; struct C_WeaponSSG08 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponSSG08@@", "13C_WeaponSSG08")}; }; struct C_WeaponAWP : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponAWP@@", "11C_WeaponAWP")}; }; struct C_WeaponG3SG1 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponG3SG1@@", "13C_WeaponG3SG1")}; }; struct C_WeaponSCAR20 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponSCAR20@@", "14C_WeaponSCAR20")}; }; struct C_WeaponTaser : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_WeaponTaser@@", "13C_WeaponTaser")}; }; struct C_Knife : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_Knife@@", "7C_Knife")}; }; struct C_Flashbang : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_Flashbang@@", "11C_Flashbang")}; }; struct C_HEGrenade : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_HEGrenade@@", "11C_HEGrenade")}; }; struct C_SmokeGrenade : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_SmokeGrenade@@", "14C_SmokeGrenade")}; }; struct C_MolotovGrenade : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_MolotovGrenade@@", "16C_MolotovGrenade")}; }; struct C_IncendiaryGrenade : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_IncendiaryGrenade@@", "19C_IncendiaryGrenade")}; }; struct C_DecoyGrenade : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_DecoyGrenade@@", "14C_DecoyGrenade")}; }; struct C_C4 : C_CSWeaponBase { - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_C4@@", "4C_C4")}; }; } diff --git a/Source/CS2/Constants/EntityTypeNames.h b/Source/CS2/Constants/EntityTypeNames.h new file mode 100644 index 00000000000..43dc7074c13 --- /dev/null +++ b/Source/CS2/Constants/EntityTypeNames.h @@ -0,0 +1,56 @@ +#pragma once + +#include +#include +#include + +namespace cs2 +{ + +constexpr auto kEntityTypeNames = TypedStaticStringPool{} + .add(WIN64_LINUX(".?AVC_CSPlayerPawn@@", "14C_CSPlayerPawn")) + .add(WIN64_LINUX(".?AVC_WeaponGlock@@", "13C_WeaponGlock")) + .add(WIN64_LINUX(".?AVC_WeaponHKP2000@@", "15C_WeaponHKP2000")) + .add(WIN64_LINUX(".?AVC_WeaponElite@@", "13C_WeaponElite")) + .add(WIN64_LINUX(".?AVC_WeaponP250@@", "12C_WeaponP250")) + .add(WIN64_LINUX(".?AVC_WeaponTec9@@", "12C_WeaponTec9")) + .add(WIN64_LINUX(".?AVC_WeaponFiveSeven@@", "17C_WeaponFiveSeven")) + .add(WIN64_LINUX(".?AVC_DEagle@@", "8C_DEagle")) + .add(WIN64_LINUX(".?AVC_WeaponMAC10@@", "13C_WeaponMAC10")) + .add(WIN64_LINUX(".?AVC_WeaponMP7@@", "11C_WeaponMP7")) + .add(WIN64_LINUX(".?AVC_WeaponMP9@@", "11C_WeaponMP9")) + .add(WIN64_LINUX(".?AVC_WeaponBizon@@", "13C_WeaponBizon")) + .add(WIN64_LINUX(".?AVC_WeaponP90@@", "11C_WeaponP90")) + .add(WIN64_LINUX(".?AVC_WeaponUMP45@@", "13C_WeaponUMP45")) + .add(WIN64_LINUX(".?AVC_WeaponMag7@@", "12C_WeaponMag7")) + .add(WIN64_LINUX(".?AVC_WeaponSawedoff@@", "16C_WeaponSawedoff")) + .add(WIN64_LINUX(".?AVC_WeaponXM1014@@", "14C_WeaponXM1014")) + .add(WIN64_LINUX(".?AVC_WeaponNOVA@@", "12C_WeaponNOVA")) + .add(WIN64_LINUX(".?AVC_WeaponM249@@", "12C_WeaponM249")) + .add(WIN64_LINUX(".?AVC_WeaponNegev@@", "13C_WeaponNegev")) + .add(WIN64_LINUX(".?AVC_WeaponGalilAR@@", "15C_WeaponGalilAR")) + .add(WIN64_LINUX(".?AVC_WeaponFamas@@", "13C_WeaponFamas")) + .add(WIN64_LINUX(".?AVC_AK47@@", "6C_AK47")) + .add(WIN64_LINUX(".?AVC_WeaponM4A1@@", "12C_WeaponM4A1")) + .add(WIN64_LINUX(".?AVC_WeaponSG556@@", "13C_WeaponSG556")) + .add(WIN64_LINUX(".?AVC_WeaponAug@@", "11C_WeaponAug")) + .add(WIN64_LINUX(".?AVC_WeaponSSG08@@", "13C_WeaponSSG08")) + .add(WIN64_LINUX(".?AVC_WeaponAWP@@", "11C_WeaponAWP")) + .add(WIN64_LINUX(".?AVC_WeaponG3SG1@@", "13C_WeaponG3SG1")) + .add(WIN64_LINUX(".?AVC_WeaponSCAR20@@", "14C_WeaponSCAR20")) + .add(WIN64_LINUX(".?AVC_WeaponTaser@@", "13C_WeaponTaser")) + .add(WIN64_LINUX(".?AVC_Knife@@", "7C_Knife")) + .add(WIN64_LINUX(".?AVC_Flashbang@@", "11C_Flashbang")) + .add(WIN64_LINUX(".?AVC_HEGrenade@@", "11C_HEGrenade")) + .add(WIN64_LINUX(".?AVC_SmokeGrenade@@", "14C_SmokeGrenade")) + .add(WIN64_LINUX(".?AVC_MolotovGrenade@@", "16C_MolotovGrenade")) + .add(WIN64_LINUX(".?AVC_IncendiaryGrenade@@", "19C_IncendiaryGrenade")) + .add(WIN64_LINUX(".?AVC_DecoyGrenade@@", "14C_DecoyGrenade")) + .add(WIN64_LINUX(".?AVCBaseAnimGraph@@", "14CBaseAnimGraph")) + .add(WIN64_LINUX(".?AVC_HEGrenadeProjectile@@", "21C_HEGrenadeProjectile")) + .add(WIN64_LINUX(".?AVC_SmokeGrenadeProjectile@@", "24C_SmokeGrenadeProjectile")) + .add(WIN64_LINUX(".?AVC_MolotovProjectile@@", "19C_MolotovProjectile")) + .add(WIN64_LINUX(".?AVC_FlashbangProjectile@@", "21C_FlashbangProjectile")) + .add(WIN64_LINUX(".?AVC_C4@@", "4C_C4")); + +} diff --git a/Source/CS2/Constants/StylePropertySymbolNames.h b/Source/CS2/Constants/StylePropertySymbolNames.h new file mode 100644 index 00000000000..c60ceb3a023 --- /dev/null +++ b/Source/CS2/Constants/StylePropertySymbolNames.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +namespace cs2 +{ + +constexpr auto kStylePropertySymbolNames = TypedStaticStringPool{} + .add("width") + .add("opacity") + .add("z-index") + .add("height") + .add("img-shadow") + .add("position") + .add("transform-origin") + .add("align") + .add("wash-color") + .add("flow-children") + .add("font") + .add("text-shadow") + .add("margin") + .add("-s2-mix-blend-mode") + .add("text-align"); + +} diff --git a/Source/CS2/Constants/StylePropertyTypeNames.h b/Source/CS2/Constants/StylePropertyTypeNames.h new file mode 100644 index 00000000000..c9eabf5526c --- /dev/null +++ b/Source/CS2/Constants/StylePropertyTypeNames.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include +#include + +namespace cs2 +{ + +constexpr auto kStylePropertyTypeNames = TypedStaticStringPool{} + .add(WIN64_LINUX(".?AVCStylePropertyWidth@panorama@@", "N8panorama19CStylePropertyWidthE")) + .add(WIN64_LINUX(".?AVCStylePropertyOpacity@panorama@@", "N8panorama21CStylePropertyOpacityE")) + .add(WIN64_LINUX(".?AVCStylePropertyZIndex@panorama@@", "N8panorama20CStylePropertyZIndexE")) + .add(WIN64_LINUX(".?AVCStylePropertyHeight@panorama@@", "N8panorama20CStylePropertyHeightE")) + .add(WIN64_LINUX(".?AVCStylePropertyImageShadow@panorama@@", "N8panorama25CStylePropertyImageShadowE")) + .add(WIN64_LINUX(".?AVCStylePropertyPosition@panorama@@", "N8panorama22CStylePropertyPositionE")) + .add(WIN64_LINUX(".?AVCStylePropertyTransformOrigin@panorama@@", "N8panorama29CStylePropertyTransformOriginE")) + .add(WIN64_LINUX(".?AVCStylePropertyAlign@panorama@@", "N8panorama19CStylePropertyAlignE")) + .add(WIN64_LINUX(".?AVCStylePropertyWashColor@panorama@@", "N8panorama23CStylePropertyWashColorE")) + .add(WIN64_LINUX(".?AVCStylePropertyFlowChildren@panorama@@", "N8panorama26CStylePropertyFlowChildrenE")) + .add(WIN64_LINUX(".?AVCStylePropertyFont@panorama@@", "N8panorama18CStylePropertyFontE")) + .add(WIN64_LINUX(".?AVCStylePropertyTextShadow@panorama@@", "N8panorama24CStylePropertyTextShadowE")) + .add(WIN64_LINUX(".?AVCStylePropertyMargin@panorama@@", "N8panorama20CStylePropertyMarginE")) + .add(WIN64_LINUX(".?AVCStylePropertyMixBlendMode@panorama@@", "N8panorama26CStylePropertyMixBlendModeE")) + .add(WIN64_LINUX(".?AVCStylePropertyTextAlign@panorama@@", "N8panorama23CStylePropertyTextAlignE")); + +} diff --git a/Source/CS2/Panorama/StyleProperties.h b/Source/CS2/Panorama/StyleProperties.h index 02f122a7409..7b3125d0591 100644 --- a/Source/CS2/Panorama/StyleProperties.h +++ b/Source/CS2/Panorama/StyleProperties.h @@ -15,37 +15,22 @@ struct LINUX_ONLY([[gnu::packed]]) CStyleProperty { }; struct CStylePropertyWidth : CStyleProperty { - static constexpr auto kName{"width"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyWidth@panorama@@", "N8panorama19CStylePropertyWidthE")}; - CUILength m_Length; }; struct CStylePropertyOpacity : CStyleProperty { - static constexpr auto kName{"opacity"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyOpacity@panorama@@", "N8panorama21CStylePropertyOpacityE")}; - float opacity; }; struct CStylePropertyZIndex : CStyleProperty { - static constexpr auto kName{"z-index"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyZIndex@panorama@@", "N8panorama20CStylePropertyZIndexE")}; - float zindex; }; struct CStylePropertyHeight : CStyleProperty { - static constexpr auto kName{"height"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyHeight@panorama@@", "N8panorama20CStylePropertyHeightE")}; - CUILength m_Height; }; struct CStylePropertyImageShadow : CStyleProperty { - static constexpr auto kName{"img-shadow"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyImageShadow@panorama@@", "N8panorama25CStylePropertyImageShadowE")}; - bool fullySet; CUILength horizontalOffset; CUILength verticalOffset; @@ -55,50 +40,32 @@ struct CStylePropertyImageShadow : CStyleProperty { }; struct CStylePropertyPosition : CStyleProperty { - static constexpr auto kName{"position"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyPosition@panorama@@", "N8panorama22CStylePropertyPositionE")}; - CUILength x; CUILength y; CUILength z; }; struct CStylePropertyTransformOrigin : CStyleProperty { - static constexpr auto kName{"transform-origin"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyTransformOrigin@panorama@@", "N8panorama29CStylePropertyTransformOriginE")}; - CUILength x; CUILength y; bool m_bParentRelative; }; struct CStylePropertyAlign : CStyleProperty { - static constexpr auto kName{"align"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyAlign@panorama@@", "N8panorama19CStylePropertyAlignE")}; - EHorizontalAlignment m_eHorizontalAlignment; EVerticalAlignment m_eVerticalAlignment; }; struct CStylePropertyWashColor : CStyleProperty { - static constexpr auto kName{"wash-color"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyWashColor@panorama@@", "N8panorama23CStylePropertyWashColorE")}; - Color color; bool fullySet; }; struct CStylePropertyFlowChildren : CStyleProperty { - static constexpr auto kName{"flow-children"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyFlowChildren@panorama@@", "N8panorama26CStylePropertyFlowChildrenE")}; - EFlowDirection m_eFlowDirection; }; struct CStylePropertyFont : CStyleProperty { - static constexpr auto kName{"font"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyFont@panorama@@", "N8panorama18CStylePropertyFontE")}; - CUtlString m_strFontFamily; float m_flFontSize; EFontStyle m_eFontStyle; @@ -107,9 +74,6 @@ struct CStylePropertyFont : CStyleProperty { }; struct CStylePropertyTextShadow : CStyleProperty { - static constexpr auto kName{"text-shadow"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyTextShadow@panorama@@", "N8panorama24CStylePropertyTextShadowE")}; - bool fullySet; CUILength horizontalOffset; CUILength verticalOffset; @@ -119,17 +83,11 @@ struct CStylePropertyTextShadow : CStyleProperty { }; struct CStylePropertyMixBlendMode : CStyleProperty { - static constexpr auto kName{"-s2-mix-blend-mode"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyMixBlendMode@panorama@@", "N8panorama26CStylePropertyMixBlendModeE")}; - EMixBlendMode m_eMixBlendMode; bool m_bSet; }; struct CStylePropertyTextAlign : CStyleProperty { - static constexpr auto kName{"text-align"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyTextAlign@panorama@@", "N8panorama23CStylePropertyTextAlignE")}; - ETextAlign m_eAlign; }; @@ -141,8 +99,6 @@ struct CStylePropertyDimensionsBase : CStyleProperty { }; struct CStylePropertyMargin : CStylePropertyDimensionsBase { - static constexpr auto kName{"margin"}; - static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVCStylePropertyMargin@panorama@@", "N8panorama20CStylePropertyMarginE")}; }; }; diff --git a/Source/FeatureHelpers/StylePropertiesSymbolsAndVMTs.h b/Source/FeatureHelpers/StylePropertiesSymbolsAndVMTs.h index 150e815130e..c05dd3d28cc 100644 --- a/Source/FeatureHelpers/StylePropertiesSymbolsAndVMTs.h +++ b/Source/FeatureHelpers/StylePropertiesSymbolsAndVMTs.h @@ -2,53 +2,38 @@ #include +#include +#include #include #include #include #include "StylePropertySymbolMap.h" -template -struct StylePropertiesSymbolsAndVMTsBase { - StylePropertiesSymbolsAndVMTsBase() = default; +struct StylePropertiesSymbolsAndVMTs { + StylePropertiesSymbolsAndVMTs() = default; - StylePropertiesSymbolsAndVMTsBase(StylePropertySymbolMap symbolMap, const VmtFinder& panoramaVmtFinder) noexcept - : symbols{symbolMap.findSymbol(StyleProperties::kName)...} - , vmts{panoramaVmtFinder.findVmt(StyleProperties::kMangledTypeName)...} + StylePropertiesSymbolsAndVMTs(StylePropertySymbolMap symbolMap, const VmtFinder& panoramaVmtFinder) noexcept { + cs2::kStylePropertySymbolNames.forEach([i = 0u, &symbolMap, this](const auto typeName) mutable { symbols[i++] = symbolMap.findSymbol(typeName); }); + cs2::kStylePropertyTypeNames.forEach([i = 0u, &panoramaVmtFinder, this](const auto typeName) mutable { vmts[i++] = panoramaVmtFinder.findVmt(typeName); }); } template [[nodiscard]] cs2::CStyleSymbol getSymbol() const noexcept { - return symbols[utils::typeIndex>()]; + return symbols[utils::typeIndex()]; } template [[nodiscard]] const void* getVmt() const noexcept { - return vmts[utils::typeIndex>()]; + return vmts[utils::typeIndex()]; } private: - std::array symbols; - std::array vmts; -}; + using StyleProperties = decltype(cs2::kStylePropertySymbolNames)::TypeList; -using StylePropertiesSymbolsAndVMTs = - StylePropertiesSymbolsAndVMTsBase< - cs2::CStylePropertyWidth, - cs2::CStylePropertyOpacity, - cs2::CStylePropertyZIndex, - cs2::CStylePropertyHeight, - cs2::CStylePropertyImageShadow, - cs2::CStylePropertyPosition, - cs2::CStylePropertyTransformOrigin, - cs2::CStylePropertyAlign, - cs2::CStylePropertyWashColor, - cs2::CStylePropertyFlowChildren, - cs2::CStylePropertyFont, - cs2::CStylePropertyTextShadow, - cs2::CStylePropertyMargin, - cs2::CStylePropertyMixBlendMode, - cs2::CStylePropertyTextAlign>; + std::array> symbols; + std::array> vmts; +}; diff --git a/Source/GameDependencies/EntitiesVMTs.h b/Source/GameDependencies/EntitiesVMTs.h index 46049dd4689..f2f6c95b51f 100644 --- a/Source/GameDependencies/EntitiesVMTs.h +++ b/Source/GameDependencies/EntitiesVMTs.h @@ -9,90 +9,19 @@ #include #include #include +#include #include #include -using KnownEntityTypes = std::tuple< - cs2::C_CSPlayerPawn, - cs2::C_WeaponGlock, - cs2::C_WeaponHKP2000, - cs2::C_WeaponElite, - cs2::C_WeaponP250, - cs2::C_WeaponTec9, - cs2::C_WeaponFiveSeven, - cs2::C_DEagle, - - cs2::C_WeaponMAC10, - cs2::C_WeaponMP7, - cs2::C_WeaponMP9, - cs2::C_WeaponBizon, - cs2::C_WeaponP90, - cs2::C_WeaponUMP45, - - cs2::C_WeaponMag7, - cs2::C_WeaponSawedoff, - cs2::C_WeaponXM1014, - cs2::C_WeaponNOVA, - cs2::C_WeaponM249, - cs2::C_WeaponNegev, - - cs2::C_WeaponGalilAR, - cs2::C_WeaponFamas, - cs2::C_AK47, - cs2::C_WeaponM4A1, - cs2::C_WeaponSG556, - cs2::C_WeaponAug, - cs2::C_WeaponSSG08, - cs2::C_WeaponAWP, - cs2::C_WeaponG3SG1, - cs2::C_WeaponSCAR20, - - cs2::C_WeaponTaser, - cs2::C_Knife, - - cs2::C_Flashbang, - cs2::C_HEGrenade, - cs2::C_SmokeGrenade, - cs2::C_MolotovGrenade, - cs2::C_IncendiaryGrenade, - cs2::C_DecoyGrenade, - - cs2::CBaseAnimGraph, - - cs2::C_HEGrenadeProjectile, - cs2::C_SmokeGrenadeProjectile, - cs2::C_MolotovProjectile, - cs2::C_FlashbangProjectile, - - cs2::C_C4 ->; +using KnownEntityTypes = decltype(cs2::kEntityTypeNames)::TypeList; struct EntitiesVMTs { EntitiesVMTs() = default; explicit EntitiesVMTs(const VmtFinder& clientVmtFinder) noexcept { - initVmts(clientVmtFinder, std::type_identity{}); + cs2::kEntityTypeNames.forEach([i = 0u, &clientVmtFinder, this] (const auto typeName) mutable { vmts[i] = clientVmtFinder.findVmt(typeName); ++i; }); } - std::array> vmts{}; - -private: - template - void initVmts(const VmtFinder& clientVmtFinder, std::type_identity>) noexcept - { - (initVmt(clientVmtFinder), ...); - } - - template - void initVmt(const VmtFinder& clientVmtFinder) noexcept - { - vmts[utils::typeIndex()] = clientVmtFinder.findVmt(EntityType::kMangledTypeName); - } - - template - [[nodiscard]] const void* getVmt() const noexcept - { - return vmts[utils::typeIndex()]; - } + std::array> vmts; }; diff --git a/Source/Osiris.vcxproj b/Source/Osiris.vcxproj index f76c23f5416..aac919d90c5 100644 --- a/Source/Osiris.vcxproj +++ b/Source/Osiris.vcxproj @@ -62,10 +62,13 @@ + + + @@ -461,6 +464,7 @@ + diff --git a/Source/Osiris.vcxproj.filters b/Source/Osiris.vcxproj.filters index 02076add1d5..a340690f4a4 100644 --- a/Source/Osiris.vcxproj.filters +++ b/Source/Osiris.vcxproj.filters @@ -1550,6 +1550,18 @@ Features\Visuals\OutlineGlow\DroppedBombOutlineGlow + + Utils + + + CS2\Constants + + + CS2\Constants + + + CS2\Constants + diff --git a/Source/Utils/TypedStaticStringPool.h b/Source/Utils/TypedStaticStringPool.h new file mode 100644 index 00000000000..8c74d5c1ac9 --- /dev/null +++ b/Source/Utils/TypedStaticStringPool.h @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include +#include + +template +class TypedStaticStringPool { +public: + using TypeList = std::tuple; + + template + [[nodiscard]] consteval auto add(const char(&str)[N]) const noexcept + { + if (str[N - 1] != '\0') + error("string must be null-terminated"); + + TypedStaticStringPool newPool; + std::ranges::copy(buffer, newPool.buffer.begin()); + std::ranges::copy(str, newPool.buffer.begin() + buffer.size()); + std::ranges::copy(stringLengths, newPool.stringLengths.begin()); + newPool.stringLengths.back() = N; + return newPool; + } + + template + void forEach(F f) const noexcept + { + std::size_t index = 0; + for (const auto stringLength : stringLengths) { + const auto str = buffer.data() + index; + f(str); + index += stringLength; + } + } + +private: + static void error(const char*); + + template + friend class TypedStaticStringPool; + + std::array buffer{}; + std::array stringLengths{}; +};