diff --git a/Game.Client/C_Precipitation.cs b/Game.Client/CClient_Precipitation.cs similarity index 94% rename from Game.Client/C_Precipitation.cs rename to Game.Client/CClient_Precipitation.cs index bad5ef7a..f2b860b8 100644 --- a/Game.Client/C_Precipitation.cs +++ b/Game.Client/CClient_Precipitation.cs @@ -4,7 +4,7 @@ using System.Numerics; namespace Game.Client; [NetworkName("CPrecipitation")] -public partial class C_Precipitation : C_BaseEntity +public partial class CClient_Precipitation : C_BaseEntity { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Client/C_NPC_Barney.cs b/Game.Client/C_Barney.cs similarity index 80% rename from Game.Client/C_NPC_Barney.cs rename to Game.Client/C_Barney.cs index a4dc5e25..3e8a0a51 100644 --- a/Game.Client/C_NPC_Barney.cs +++ b/Game.Client/C_Barney.cs @@ -5,7 +5,7 @@ namespace Game.Client; [NetworkName("CNPC_Barney")] -public partial class C_NPC_Barney : C_AI_BaseNPC +public partial class C_Barney : C_AI_BaseNPC { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Client/C_BaseAnimatingOverlay.cs b/Game.Client/C_BaseAnimatingOverlay.cs index 742c13d7..a389d8b4 100644 --- a/Game.Client/C_BaseAnimatingOverlay.cs +++ b/Game.Client/C_BaseAnimatingOverlay.cs @@ -10,6 +10,9 @@ namespace Game.Client; [NetworkName("CBaseAnimatingOverlay")] public partial class C_BaseAnimatingOverlay : C_BaseAnimating { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable("DT_OverlayVars")] public static readonly NetworkProp[] OverlayVarsProps = [ new(nameof(AnimOverlay)) { Encoding = NetEncoding.List, Count = MAX_OVERLAYS, DataTable = "DT_Animationlayer", Proxy = typeof(AnimOverlayProxy) }, diff --git a/Game.Client/C_BaseEntity.cs b/Game.Client/C_BaseEntity.cs index 91e3b47a..1f516548 100644 --- a/Game.Client/C_BaseEntity.cs +++ b/Game.Client/C_BaseEntity.cs @@ -303,6 +303,10 @@ public void SetClassname(ReadOnlySpan classname) { static readonly char[] GetClassname__outstr = new char[256]; public ReadOnlySpan GetClassname() { +#if GMOD_DLL + if (RealClassName != 0 && Game.Client.GarrysMod.NetworkString.Convert(RealClassName) is string realClassName) + return realClassName; +#endif if (!string.IsNullOrEmpty(Classname)) return Classname; #if GMOD_DLL @@ -319,8 +323,16 @@ public ReadOnlySpan GetClassname() { } } - if (!gotname) - strcpy(GetClassname__outstr, GetType().Name); + if (!gotname) { + string typeName = GetType().Name; + if (!typeName.StartsWith("C_") && !(typeName.Length > 1 && typeName[0] == 'C' && char.IsUpper(typeName[1]))) + typeName = "C_" + typeName; +#if WIN32 + strcpy(GetClassname__outstr, $"class {typeName}"); +#else + strcpy(GetClassname__outstr, $"{typeName.Length}{typeName}"); +#endif + } return GetClassname__outstr.SliceNullTerminatedString(); } diff --git a/Game.Client/C_BaseFlex.cs b/Game.Client/C_BaseFlex.cs index bf252d96..5a0935cf 100644 --- a/Game.Client/C_BaseFlex.cs +++ b/Game.Client/C_BaseFlex.cs @@ -144,6 +144,9 @@ public class EmphasizedPhoneme [NetworkName("CBaseFlex")] public partial class C_BaseFlex : C_BaseAnimatingOverlay, IHasLocalToGlobalFlexSettings { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + static readonly ConVar g_CV_PhonemeDelay = new("phonemedelay", "0", FCvar.None, "Phoneme delay to account for sound system latency."); static readonly ConVar g_CV_PhonemeFilter = new("phonemefilter", "0.08", FCvar.None, "Time duration of box filter to pass over phonemes."); static readonly ConVar g_CV_FlexRules = new("flex_rules", "1", FCvar.None, "Allow flex animation rules to run."); diff --git a/Game.Client/C_BeamSpotlight.cs b/Game.Client/C_BeamSpotLight.cs similarity index 96% rename from Game.Client/C_BeamSpotlight.cs rename to Game.Client/C_BeamSpotLight.cs index 68abfcff..90597064 100644 --- a/Game.Client/C_BeamSpotlight.cs +++ b/Game.Client/C_BeamSpotLight.cs @@ -5,7 +5,7 @@ namespace Game.Client; [LinkEntityToClass("beam_spotlight")] [NetworkName("CBeamSpotlight")] -public partial class C_BeamSpotlight : C_BaseEntity +public partial class C_BeamSpotLight : C_BaseEntity { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Client/C_BoneManipulate.cs b/Game.Client/C_BoneManipulate.cs index 1e704ed3..556421f3 100644 --- a/Game.Client/C_BoneManipulate.cs +++ b/Game.Client/C_BoneManipulate.cs @@ -9,6 +9,13 @@ namespace Game.Client; [NetworkName("CBoneManipulate")] public partial class C_BoneManipulate : C_BaseEntity { + [PredictionTable] + public static readonly new PredictionField[] Prediction = [ + new(nameof(BonePos)) { Type = FieldType.PositionVector }, + new(nameof(BoneAng)) { Type = FieldType.PositionVector }, + new(nameof(BoneScale)) { Type = FieldType.PositionVector }, + ]; + [NetworkTable] public static readonly new NetworkProp[] Props = [ new(nameof(BonePos)) { Bits = 0, Flags = PropFlags.NoScale }, diff --git a/Game.Client/C_NPC_CombineGunship.cs b/Game.Client/C_CombineGunship.cs similarity index 85% rename from Game.Client/C_NPC_CombineGunship.cs rename to Game.Client/C_CombineGunship.cs index 76c7f1ce..83872fe6 100644 --- a/Game.Client/C_NPC_CombineGunship.cs +++ b/Game.Client/C_CombineGunship.cs @@ -4,7 +4,7 @@ using System.Numerics; namespace Game.Client; [NetworkName("CNPC_CombineGunship", Table = "DT_CombineGunship")] -public partial class C_NPC_CombineGunship : C_BaseHelicopter +public partial class C_CombineGunship : C_BaseHelicopter { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Client/C_FlexManipulate.cs b/Game.Client/C_FlexManipulate.cs index db1d6e1e..6a51e87c 100644 --- a/Game.Client/C_FlexManipulate.cs +++ b/Game.Client/C_FlexManipulate.cs @@ -7,6 +7,9 @@ namespace Game.Client; [NetworkName("CFlexManipulate")] public partial class C_FlexManipulate : C_BaseEntity { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ new(nameof(ExScale)) { Bits = 0, Flags = PropFlags.NoScale }, diff --git a/Game.Client/C_PlayerResource.cs b/Game.Client/C_PlayerResource.cs index d6648f4a..7d73f201 100644 --- a/Game.Client/C_PlayerResource.cs +++ b/Game.Client/C_PlayerResource.cs @@ -17,6 +17,19 @@ public static class PlayerResourceGlobals [NetworkName("CPlayerResource", NoBase = true)] public partial class C_PlayerResource : C_BaseEntity { + [PredictionTable] + public static readonly new PredictionField[] Prediction = [ + new(nameof(Name)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Ping)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Score)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Deaths)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Connected)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Team)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Alive)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Health)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Armor)) { Flags = FieldTypeDescFlags.Private }, + ]; + [NetworkTable] public static readonly new NetworkProp[] Props = [ new(nameof(Ping)) { Bits = 12, Flags = PropFlags.Unsigned }, @@ -47,7 +60,7 @@ public partial class C_PlayerResource : C_BaseEntity InlineArrayMaxPlayersPlusOne Armor = new(); const string PLAYER_UNCONNECTED_NAME = "unconnected"; - readonly string?[] Name = new string?[Constants.MAX_PLAYERS + 1]; + InlineArrayMaxPlayersPlusOne Name; public C_PlayerResource() => g_pPlayerResource = this; diff --git a/Game.Client/C_Props.cs b/Game.Client/C_Props.cs index 0402a2c6..94536779 100644 --- a/Game.Client/C_Props.cs +++ b/Game.Client/C_Props.cs @@ -6,9 +6,9 @@ namespace Game.Client; using System.Numerics; -using FIELD_PBM = Source.FIELD; +using FIELD_PBM = Source.FIELD; using FIELD_BPD = Source.FIELD; -using FIELD_PPM = Source.FIELD; +using FIELD_PPM = Source.FIELD; [NetworkName("CDynamicProp")] public partial class C_DynamicProp : C_BreakableProp @@ -24,7 +24,7 @@ public partial class C_DynamicProp : C_BreakableProp [NetworkName("CPhysicsPropMultiplayer")] -public partial class PhysicsPropMultiplayer : C_PhysicsProp +public partial class CPhysicsPropMultiplayer : C_PhysicsProp { [NetworkTable] public static readonly new NetworkProp[] Props = [ @@ -45,7 +45,7 @@ public partial class PhysicsPropMultiplayer : C_PhysicsProp } [NetworkName("CPhysBoxMultiplayer")] -public partial class PhysBoxMultiplayer : C_PhysBox +public partial class CPhysBoxMultiplayer : C_PhysBox { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Client/C_EnvQuadraticBeam.cs b/Game.Client/C_QuadraticBeam.cs similarity index 93% rename from Game.Client/C_EnvQuadraticBeam.cs rename to Game.Client/C_QuadraticBeam.cs index 44ed36ec..732d2003 100644 --- a/Game.Client/C_EnvQuadraticBeam.cs +++ b/Game.Client/C_QuadraticBeam.cs @@ -4,7 +4,7 @@ using System.Numerics; namespace Game.Client; [NetworkName("CEnvQuadraticBeam", Table = "DT_QuadraticBeam")] -public partial class C_EnvQuadraticBeam : C_BaseEntity +public partial class C_QuadraticBeam : C_BaseEntity { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Client/C_NPC_RollerMine.cs b/Game.Client/C_RollerMine.cs similarity index 91% rename from Game.Client/C_NPC_RollerMine.cs rename to Game.Client/C_RollerMine.cs index afc16932..62ef1494 100644 --- a/Game.Client/C_NPC_RollerMine.cs +++ b/Game.Client/C_RollerMine.cs @@ -4,7 +4,7 @@ using System.Numerics; namespace Game.Client; [NetworkName("CNPC_RollerMine", Table = "DT_RollerMine")] -public partial class C_NPC_RollerMine : C_AI_BaseNPC +public partial class C_RollerMine : C_AI_BaseNPC { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Client/C_RagdollProp.cs b/Game.Client/C_ServerRagdoll.cs similarity index 94% rename from Game.Client/C_RagdollProp.cs rename to Game.Client/C_ServerRagdoll.cs index 613bbee6..73e00c87 100644 --- a/Game.Client/C_RagdollProp.cs +++ b/Game.Client/C_ServerRagdoll.cs @@ -5,7 +5,7 @@ using System.Numerics; namespace Game.Client; [NetworkName("CRagdollProp", Table = "DT_Ragdoll")] -public partial class C_RagdollProp : C_BaseAnimating +public partial class C_ServerRagdoll : C_BaseAnimating { const int RAGDOLL_MAX_ELEMENTS = 32; [NetworkTable] diff --git a/Game.Client/C_RagdollPropAttached.cs b/Game.Client/C_ServerRagdollAttached.cs similarity index 93% rename from Game.Client/C_RagdollPropAttached.cs rename to Game.Client/C_ServerRagdollAttached.cs index 371d4c3c..7d08352a 100644 --- a/Game.Client/C_RagdollPropAttached.cs +++ b/Game.Client/C_ServerRagdollAttached.cs @@ -5,7 +5,7 @@ namespace Game.Client; [NetworkName("CRagdollPropAttached", Table = "DT_Ragdoll_Attached")] -public partial class C_RagdollPropAttached : C_RagdollProp +public partial class C_ServerRagdollAttached : C_ServerRagdoll { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Client/C_Team.cs b/Game.Client/C_Team.cs index e1b0bf4e..91de8102 100644 --- a/Game.Client/C_Team.cs +++ b/Game.Client/C_Team.cs @@ -44,6 +44,17 @@ public static bool ArePlayersOnSameTeam(int playerIndex1, int playerIndex2){ [NetworkName("CTeam")] public partial class C_Team : C_BaseEntity { + [PredictionTable] + public static readonly new PredictionField[] Prediction = [ + new(nameof(Teamname)) { Type = FieldType.StringCharacter, Flags = FieldTypeDescFlags.Private }, + new(nameof(Score)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(RoundsWon)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Deaths)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Ping)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(Packetloss)) { Flags = FieldTypeDescFlags.Private }, + new(nameof(TeamNum)) { Flags = FieldTypeDescFlags.Private }, + ]; + [NetworkTable(NoBase = true)] public static readonly new NetworkProp[] Props = [ nameof(TeamNum), diff --git a/Game.Client/GarrysMod/C_GMOD_Player.cs b/Game.Client/GarrysMod/C_GMOD_Player.cs index 2d3d8c4d..5733abc6 100644 --- a/Game.Client/GarrysMod/C_GMOD_Player.cs +++ b/Game.Client/GarrysMod/C_GMOD_Player.cs @@ -21,6 +21,9 @@ namespace Game.Client.GarrysMod; [NetworkName("CGMOD_Player")] public partial class C_GMOD_Player() : C_HL2MP_Player() { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ nameof(GModPlayerFlags), diff --git a/Game.Client/HL1/C_BaseHL1CombatWeapon.cs b/Game.Client/HL1/C_BaseHL1CombatWeapon.cs index 5ac2205b..95ff9c50 100644 --- a/Game.Client/HL1/C_BaseHL1CombatWeapon.cs +++ b/Game.Client/HL1/C_BaseHL1CombatWeapon.cs @@ -7,6 +7,9 @@ namespace Game.Client.HL1; [NetworkName("CBaseHL1CombatWeapon")] public partial class C_BaseHL1CombatWeapon : C_BaseCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Client/HL1/C_BaseHL1MPCombatWeapon.cs b/Game.Client/HL1/C_BaseHL1MPCombatWeapon.cs index 4dbd2286..56444fac 100644 --- a/Game.Client/HL1/C_BaseHL1MPCombatWeapon.cs +++ b/Game.Client/HL1/C_BaseHL1MPCombatWeapon.cs @@ -7,6 +7,9 @@ namespace Game.Client.HL1; [NetworkName("CBaseHL1MPCombatWeapon")] public partial class C_BaseHL1MPCombatWeapon : C_BaseHL1CombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Client/HL2/C_Weapon_Stubs_HL2.cs b/Game.Client/HL2/C_Weapon_Stubs_HL2.cs index 48d712d4..38a1ecc3 100644 --- a/Game.Client/HL2/C_Weapon_Stubs_HL2.cs +++ b/Game.Client/HL2/C_Weapon_Stubs_HL2.cs @@ -10,6 +10,9 @@ namespace Game.Client.HL2; [NetworkName("CWeaponCycler")] public partial class C_WeaponCycler : C_BaseCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; @@ -20,6 +23,9 @@ public partial class C_WeaponCycler : C_BaseCombatWeapon [NetworkName("CWeaponAnnabelle")] public partial class C_WeaponAnnabelle : C_BaseHLCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; @@ -30,6 +36,9 @@ public partial class C_WeaponAnnabelle : C_BaseHLCombatWeapon [NetworkName("CWeaponAlyxGun")] public partial class C_WeaponAlyxGun : C_HLSelectFireMachineGun { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; @@ -40,6 +49,9 @@ public partial class C_WeaponAlyxGun : C_HLSelectFireMachineGun [NetworkName("CWeaponCitizenPackage")] public partial class C_WeaponCitizenPackage : C_BaseHLCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; @@ -50,6 +62,9 @@ public partial class C_WeaponCitizenPackage : C_BaseHLCombatWeapon [NetworkName("CWeaponCitizenSuitcase")] public partial class C_WeaponCitizenSuitcase : C_WeaponCitizenPackage { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; @@ -60,6 +75,9 @@ public partial class C_WeaponCitizenSuitcase : C_WeaponCitizenPackage [NetworkName("CWeaponCubemap")] public partial class C_WeaponCubemap : C_BaseCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; @@ -71,6 +89,9 @@ public partial class C_WeaponCubemap : C_BaseCombatWeapon [NetworkName("CWeaponOldManHarpoon")] public partial class C_WeaponOldManHarpoon : C_WeaponCitizenPackage { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Server/BaseEntity.cs b/Game.Server/BaseEntity.cs index 6e2f300e..12636d55 100644 --- a/Game.Server/BaseEntity.cs +++ b/Game.Server/BaseEntity.cs @@ -796,6 +796,7 @@ internal static void SendProxy_SimulationTime(SendProp prop, object instance, IF public virtual int Save(ISave save) { throw new NotImplementedException(); } + // todo: GMod's Restore calls SetMaterialOverride(OverrideMaterialName) and SetClassname(RealClassNameString) again when they are not empty public virtual int Restore(IRestore save) { throw new NotImplementedException(); } public virtual bool ShouldSavePhysics() => true; public virtual void OnSave(IEntitySaveUtils utils) { @@ -2744,6 +2745,12 @@ public void CalcAbsoluteVelocity() { public void SetClassname(ReadOnlySpan classname) { Classname = new(classname); +#if GMOD_DLL + if ((ObjectCaps() & EntityCapabilities.AcrossTransition) != 0) { + RealClassName = (ushort)Game.Server.GarrysMod.NetworkString.Add(Classname); + strcpy(RealClassNameString, classname); + } +#endif } public Edict Edict() => NetworkProp().Edict(); @@ -2910,6 +2917,10 @@ public virtual ReadOnlySpan GetClassname() { // DEFINE_THINKFUNC( ShadowCastDistThink ), DEFINE.FIELD(nameof(EffectEntity), FieldType.EHandle), // DEFINE_ARRAY( m_nModelIndexOverrides, FIELD_INTEGER, MAX_VISION_MODES ), +#if GMOD_DLL + DEFINE.AUTO_ARRAY(nameof(OverrideMaterialName), FieldType.Character), + DEFINE.AUTO_ARRAY(nameof(RealClassNameString), FieldType.Character), +#endif ]); public virtual DataMap? GetDataDescMap() => DataDesc; @@ -3467,6 +3478,7 @@ public void TraceAttackToTriggers(in TakeDamageInfo info, in Vector3 start, in V public virtual void SetUseType(int type) { } InlineArray256 OverrideMaterialName; + InlineArray256 RealClassNameString; public virtual void SetMaterialOverride(ReadOnlySpan name) { if (!name.IsEmpty && name[0] != '\0') { diff --git a/Game.Shared/BaseParticleEntity.cs b/Game.Shared/BaseParticleEntity.cs index 871f70b2..b005d7ea 100644 --- a/Game.Shared/BaseParticleEntity.cs +++ b/Game.Shared/BaseParticleEntity.cs @@ -21,6 +21,9 @@ public partial class BaseParticleEntity : BaseEntity #endif { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Shared/BaseToggle.cs b/Game.Shared/BaseToggle.cs index 53a732d7..d4668a6d 100644 --- a/Game.Shared/BaseToggle.cs +++ b/Game.Shared/BaseToggle.cs @@ -8,6 +8,9 @@ namespace Game.Shared; [NetworkName("CBaseToggle")] public partial class BaseToggle : BaseEntity { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ new(nameof(FinalDest)) { Bits = 0, Flags = PropFlags.NoScale }, diff --git a/Game.Shared/GarrysMod/BaseHL2MPBludgeonWeapon.cs b/Game.Shared/GarrysMod/BaseHL2MPBludgeonWeapon.cs index 47c962b1..12d1ff1c 100644 --- a/Game.Shared/GarrysMod/BaseHL2MPBludgeonWeapon.cs +++ b/Game.Shared/GarrysMod/BaseHL2MPBludgeonWeapon.cs @@ -9,6 +9,9 @@ namespace Game.Shared.GarrysMod; [NetworkName("CBaseHL2MPBludgeonWeapon")] public partial class BaseHL2MPBludgeonWeapon : BaseHL2MPCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Shared/GarrysMod/SENT_Anim.cs b/Game.Shared/GarrysMod/SENT_anim.cs similarity index 98% rename from Game.Shared/GarrysMod/SENT_Anim.cs rename to Game.Shared/GarrysMod/SENT_anim.cs index 3428b0f1..e45fe622 100644 --- a/Game.Shared/GarrysMod/SENT_Anim.cs +++ b/Game.Shared/GarrysMod/SENT_anim.cs @@ -22,9 +22,9 @@ namespace Game.Server; [NetworkName("CSENT_anim")] public partial class #if CLIENT_DLL - C_SENT_Anim : C_BaseAnimatingOverlay + C_SENT_anim : C_BaseAnimatingOverlay #elif GAME_DLL - SENT_Anim : BaseAnimatingOverlay, IMotionEvent + SENT_anim : BaseAnimatingOverlay, IMotionEvent #endif { [NetworkTable] @@ -36,9 +36,9 @@ public partial class public readonly ScriptedEntity ScriptedEntity = new(); #if CLIENT_DLL - public C_SENT_Anim() { + public C_SENT_anim() { #else - public SENT_Anim() { + public SENT_anim() { #endif ScriptedEntity.Init(this, 1); } diff --git a/Game.Shared/GarrysMod/SENT_Point.cs b/Game.Shared/GarrysMod/SENT_point.cs similarity index 96% rename from Game.Shared/GarrysMod/SENT_Point.cs rename to Game.Shared/GarrysMod/SENT_point.cs index 5ebdefb3..f9119255 100644 --- a/Game.Shared/GarrysMod/SENT_Point.cs +++ b/Game.Shared/GarrysMod/SENT_point.cs @@ -16,9 +16,9 @@ namespace Game.Server; [NetworkName("CSENT_point")] public partial class #if CLIENT_DLL - C_SENT_Point + C_SENT_point #else - SENT_Point + SENT_point #endif : BaseEntity { @@ -31,9 +31,9 @@ public partial class public readonly ScriptedEntity ScriptedEntity = new(); #if CLIENT_DLL - public C_SENT_Point() { + public C_SENT_point() { #else - public SENT_Point() { + public SENT_point() { #endif ScriptedEntity.Init(this, 1); } diff --git a/Game.Shared/GarrysMod/Weapon357.cs b/Game.Shared/GarrysMod/Weapon357.cs index 171a9053..9a67c6e2 100644 --- a/Game.Shared/GarrysMod/Weapon357.cs +++ b/Game.Shared/GarrysMod/Weapon357.cs @@ -11,6 +11,9 @@ namespace Game.Shared.GarrysMod; [NetworkName("CWeapon357")] public partial class Weapon357 : BaseHL2MPCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Shared/GarrysMod/WeaponAR2.cs b/Game.Shared/GarrysMod/WeaponAR2.cs index 2678d21c..0f1c75c1 100644 --- a/Game.Shared/GarrysMod/WeaponAR2.cs +++ b/Game.Shared/GarrysMod/WeaponAR2.cs @@ -7,6 +7,9 @@ namespace Game.Shared.GarrysMod; [NetworkName("CWeaponAR2")] public partial class WeaponAR2 : HL2MPMachineGun { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Shared/GarrysMod/WeaponCrowbar.cs b/Game.Shared/GarrysMod/WeaponCrowbar.cs index f3badca9..8ec6f5ea 100644 --- a/Game.Shared/GarrysMod/WeaponCrowbar.cs +++ b/Game.Shared/GarrysMod/WeaponCrowbar.cs @@ -16,6 +16,9 @@ namespace Game.Shared.GarrysMod; [NetworkName("CWeaponCrowbar")] public partial class WeaponCrowbar : BaseHL2MPBludgeonWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Shared/GarrysMod/WeaponGModBase.cs b/Game.Shared/GarrysMod/WeaponGModBase.cs index 7994018f..d0ed7d21 100644 --- a/Game.Shared/GarrysMod/WeaponGModBase.cs +++ b/Game.Shared/GarrysMod/WeaponGModBase.cs @@ -48,6 +48,9 @@ public partial class #endif : BaseCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; @@ -108,6 +111,9 @@ public partial class #endif : WeaponHL2MPBase { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Shared/GarrysMod/WeaponSMG1.cs b/Game.Shared/GarrysMod/WeaponSMG1.cs index c596b03d..6a59760b 100644 --- a/Game.Shared/GarrysMod/WeaponSMG1.cs +++ b/Game.Shared/GarrysMod/WeaponSMG1.cs @@ -8,6 +8,9 @@ namespace Game.Shared.GarrysMod; [NetworkName("CWeaponSMG1")] public partial class WeaponSMG1 : HL2MPMachineGun { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Shared/GarrysMod/WeaponSWEP.cs b/Game.Shared/GarrysMod/WeaponSWEP.cs index 3b97487b..f7f66337 100644 --- a/Game.Shared/GarrysMod/WeaponSWEP.cs +++ b/Game.Shared/GarrysMod/WeaponSWEP.cs @@ -24,6 +24,9 @@ public partial class WeaponSWEP : BaseHL2MPCombatWeapon #endif { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ new(nameof(ScriptedEntity)) { Encoding = NetEncoding.DataTable, DataTable = "DT_ScriptedEntity" }, diff --git a/Game.Shared/GarrysMod/WeaponSLAM.cs b/Game.Shared/GarrysMod/Weapon_SLAM.cs similarity index 98% rename from Game.Shared/GarrysMod/WeaponSLAM.cs rename to Game.Shared/GarrysMod/Weapon_SLAM.cs index c066c235..c5bcfb68 100644 --- a/Game.Shared/GarrysMod/WeaponSLAM.cs +++ b/Game.Shared/GarrysMod/Weapon_SLAM.cs @@ -5,7 +5,7 @@ namespace Game.Shared.GarrysMod; [LinkEntityToClass("weapon_slam")] [PrecacheWeaponRegister("weapon_slam")] [NetworkName("CWeapon_SLAM")] -public partial class WeaponSLAM : BaseHL2MPCombatWeapon +public partial class Weapon_SLAM : BaseHL2MPCombatWeapon { [NetworkTable] public static readonly new NetworkProp[] Props = [ diff --git a/Game.Shared/HL2/BaseHLCombatWeapon.cs b/Game.Shared/HL2/BaseHLCombatWeapon.cs index 77f6d85e..16e730b9 100644 --- a/Game.Shared/HL2/BaseHLCombatWeapon.cs +++ b/Game.Shared/HL2/BaseHLCombatWeapon.cs @@ -22,6 +22,9 @@ public static class HLCombatWeaponGlobals [NetworkName("CBaseHLCombatWeapon")] public partial class BaseHLCombatWeapon : BaseCombatWeapon { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ ]; diff --git a/Game.Shared/SpriteTrail.cs b/Game.Shared/SpriteTrail.cs index 5138d3d3..b5acb92c 100644 --- a/Game.Shared/SpriteTrail.cs +++ b/Game.Shared/SpriteTrail.cs @@ -7,6 +7,9 @@ namespace Game.Shared; [NetworkName("CSpriteTrail")] public partial class SpriteTrail : Sprite { + [PredictionTable] + public static readonly new PredictionField[] Prediction = []; + [NetworkTable] public static readonly new NetworkProp[] Props = [ new(nameof(LifeTime)) { Encoding = NetEncoding.Float, Bits = 0, Flags = PropFlags.NoScale }, diff --git a/Source.CodeAnalysis.NetworkVars/NetworkVarGenerator.Tables.cs b/Source.CodeAnalysis.NetworkVars/NetworkVarGenerator.Tables.cs index 66108e0c..fe4da0ff 100644 --- a/Source.CodeAnalysis.NetworkVars/NetworkVarGenerator.Tables.cs +++ b/Source.CodeAnalysis.NetworkVars/NetworkVarGenerator.Tables.cs @@ -436,7 +436,7 @@ private static void EmitTables(SourceProductionContext spc, ImmutableArray 0; + && predElement != null && (predElement.SpecialType != SpecialType.System_Char || SettingEnum(entry.Settings, "Type") == "StringCharacter") && predLength > 0; string? fieldType = SettingEnum(entry.Settings, "Type") ?? InferFieldType(predArray ? predElement! : memberType); if (fieldType == null) { diagnostics.Add(new TableDiagnostic(UnsupportedPredicted, entry.Location, entry.Path, memberType.ToDisplayString())); @@ -465,7 +465,7 @@ private static void EmitTables(SourceProductionContext spc, ImmutableArray
!m.IsImplicitlyDeclared); + bool declaresPredMap = baseType == null || predictionLists.Count > 0; if (plain) { if (isClient && ownPredMap && predicted.Count > 0) { sb.Append(indent).AppendLine("\tpublic static readonly global::Source.Common.DataMap PredMap = new(new global::Source.Common.TypeDescription[] {"); @@ -518,7 +519,7 @@ private static void EmitTables(SourceProductionContext spc, ImmutableArray
ClientClass;"); - if (isEntity && !type.GetMembers("PredMap").Any(m => !m.IsImplicitlyDeclared)) { + if (isEntity && ownPredMap && declaresPredMap) { sb.Append(indent).AppendLine(baseType == null ? "\tpublic static readonly global::Source.Common.DataMap PredMap = new(new global::Source.Common.TypeDescription[] {" : "\tpublic static readonly new global::Source.Common.DataMap PredMap = new(new global::Source.Common.TypeDescription[] {"); foreach (string entry in predicted) sb.Append(indent).Append("\t\t").Append(entry).AppendLine(","); @@ -536,7 +537,7 @@ private static void EmitTables(SourceProductionContext spc, ImmutableArray
0)) + PredictionMapModel? map = isClient && ownPredMap && ((isEntity && declaresPredMap) || (plain && predicted.Count > 0)) ? new PredictionMapModel(type.ToDisplayString() + ".PredMap", "PredMap", typeDisplay, string.Join("\n", entries), string.Join("\n", embeddedMaps)) : null; @@ -887,6 +888,7 @@ private static string PredictionDescription(string fieldType, ISymbol member, st case SpecialType.System_Int32: case SpecialType.System_UInt32: return "Integer"; case SpecialType.System_Single: return "Float"; case SpecialType.System_Double: return "Double"; + case SpecialType.System_String: return "String"; } switch (type.OriginalDefinition.ToDisplayString()) { case "System.Numerics.Vector3": case "Source.Common.Mathematics.QAngle": return "Vector";