Send server rules over the network (#10847)
Add a new InfoSystem that sends SharedInfo from the server to client when requested. Currently, only the rule header and rule text is sent. Previously, the rule header and rule text was bundled in the client, which means that the client would only display rules that it was built with, even if the server has different rules. This allows servers all running the same build to send different rules. This could be useful, for example, for servers running the official builds to send different rulesets without a client rebuild.
This commit is contained in:
@@ -17,7 +17,9 @@ public sealed class RulesManager : SharedRulesManager
|
||||
[Dependency] private readonly IStateManager _stateManager = default!;
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
[Dependency] private readonly INetManager _netManager = default!;
|
||||
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
||||
|
||||
private InfoSection rulesSection = new InfoSection("", "", false);
|
||||
private bool _shouldShowRules;
|
||||
|
||||
public void Initialize()
|
||||
@@ -72,4 +74,20 @@ public sealed class RulesManager : SharedRulesManager
|
||||
var message = _netManager.CreateNetMessage<RulesAcceptedMessage>();
|
||||
_netManager.ClientSendMessage(message);
|
||||
}
|
||||
|
||||
public void UpdateRules()
|
||||
{
|
||||
var rules = _sysMan.GetEntitySystem<InfoSystem>().Rules;
|
||||
rulesSection.SetText(rules.Title, rules.Text, true);
|
||||
}
|
||||
|
||||
public Control RulesSection()
|
||||
{
|
||||
if (rulesSection.Disposed)
|
||||
{
|
||||
rulesSection = new InfoSection("", "", false);
|
||||
}
|
||||
UpdateRules();
|
||||
return rulesSection;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user