diff --git a/Alliance.Client/_Module/SubModule.xml b/Alliance.Client/_Module/SubModule.xml index 909f922f..71fa9312 100644 --- a/Alliance.Client/_Module/SubModule.xml +++ b/Alliance.Client/_Module/SubModule.xml @@ -2,7 +2,7 @@ - + diff --git a/Alliance.Common/CommonProps.props b/Alliance.Common/CommonProps.props index f0b7a664..f06c85e4 100644 --- a/Alliance.Common/CommonProps.props +++ b/Alliance.Common/CommonProps.props @@ -1,5 +1,5 @@ - 0.0.9.9 + 0.1.0.0 diff --git a/Alliance.Common/Extensions/IHandlerRegister.cs b/Alliance.Common/Extensions/IHandlerRegister.cs index d1fbca7c..04953d6f 100644 --- a/Alliance.Common/Extensions/IHandlerRegister.cs +++ b/Alliance.Common/Extensions/IHandlerRegister.cs @@ -4,6 +4,8 @@ namespace Alliance.Common.Extensions { /// /// Implement this interface in your extension if you need to register network messages handlers. + /// Your class will be instantiated automatically and the Register method will be called. + /// /!\ Do not use directly on a MissionBehavior as it will cause unwanted instantiation. /// public interface IHandlerRegister { diff --git a/Alliance.Editor/_Module/SubModule.xml b/Alliance.Editor/_Module/SubModule.xml index 2ffca9d7..a6c9412e 100644 --- a/Alliance.Editor/_Module/SubModule.xml +++ b/Alliance.Editor/_Module/SubModule.xml @@ -2,7 +2,7 @@ - + diff --git a/Alliance.Server/Extensions/ClassLimiter/Behaviors/ClassLimiterBehavior.cs b/Alliance.Server/Extensions/ClassLimiter/Behaviors/ClassLimiterBehavior.cs index bdb4fb7c..1c4ce394 100644 --- a/Alliance.Server/Extensions/ClassLimiter/Behaviors/ClassLimiterBehavior.cs +++ b/Alliance.Server/Extensions/ClassLimiter/Behaviors/ClassLimiterBehavior.cs @@ -5,7 +5,7 @@ namespace Alliance.Server.Extensions.ClassLimiter.Behaviors { - public class ClassLimiterBehavior : MissionNetwork, IHandlerRegister + public class ClassLimiterBehavior : MissionNetwork { private MultiplayerRoundController _roundController; @@ -51,20 +51,5 @@ private void OnRoundStart() // Refresh class limits on every round ClassLimiterModel.Instance.Init(); } - - public void Register(GameNetwork.NetworkMessageHandlerRegisterer reg) - { - reg.Register(HandleRequestUsage); - } - - public bool HandleRequestUsage(NetworkCommunicator peer, RequestCharacterUsage message) - { - // DEBUG test - //foreach (BasicCharacterObject character in MBObjectManager.Instance.GetObjectTypeList()) - //{ - // ClassLimiterModel.Instance.TryReserveCharacterSlot(character); - //} - return ClassLimiterModel.Instance.HandleRequestUsage(peer, message); - } } } diff --git a/Alliance.Server/Extensions/ClassLimiter/Handlers/ClassLimiterHandler.cs b/Alliance.Server/Extensions/ClassLimiter/Handlers/ClassLimiterHandler.cs new file mode 100644 index 00000000..4d40b96e --- /dev/null +++ b/Alliance.Server/Extensions/ClassLimiter/Handlers/ClassLimiterHandler.cs @@ -0,0 +1,15 @@ +using Alliance.Common.Extensions; +using Alliance.Common.Extensions.ClassLimiter.Models; +using Alliance.Common.Extensions.ClassLimiter.NetworkMessages.FromClient; +using TaleWorlds.MountAndBlade; + +namespace Alliance.Server.Extensions.ClassLimiter.Handlers +{ + public class ClassLimiterHandler : IHandlerRegister + { + public void Register(GameNetwork.NetworkMessageHandlerRegisterer reg) + { + reg.Register(ClassLimiterModel.Instance.HandleRequestUsage); + } + } +} diff --git a/Alliance.Server/_Module/SubModule.xml b/Alliance.Server/_Module/SubModule.xml index 2625057b..d342ee1e 100644 --- a/Alliance.Server/_Module/SubModule.xml +++ b/Alliance.Server/_Module/SubModule.xml @@ -2,7 +2,7 @@ - +