Resolve mission briefing notifications client-side.

This commit is contained in:
Paul Chote
2025-11-03 10:35:02 +00:00
parent d4fd66adf9
commit f8b9dfc73e
2 changed files with 11 additions and 22 deletions

View File

@@ -658,10 +658,6 @@ namespace OpenRA.Mods.Common.Server
server.SendFluentMessage(TwoHumansRequired);
else if (server.Map.Players.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
server.SendFluentMessage(MapBotsDisabled);
var briefing = MissionBriefingOrDefault(server);
if (briefing != null)
server.SendMessage(briefing);
}
}
@@ -1453,15 +1449,6 @@ namespace OpenRA.Mods.Common.Server
return !validFactions.Contains(askedFaction) ? "Random" : askedFaction;
}
static string MissionBriefingOrDefault(S server)
{
var missionData = server.Map.WorldActorInfo.TraitInfoOrDefault<MissionDataInfo>();
if (missionData != null && !string.IsNullOrEmpty(missionData.Briefing))
return missionData.Briefing.Replace("\\n", "\n");
return null;
}
public void ClientJoined(S server, Connection conn)
{
lock (server.LobbyInfo)
@@ -1474,13 +1461,6 @@ namespace OpenRA.Mods.Common.Server
// Validate whether color is allowed and get an alternative if it isn't
if (client.Slot != null && !server.LobbyInfo.Slots[client.Slot].LockColor)
client.Color = SanitizePlayerColor(server, client.Color, client.Index);
// Report any custom map details
// HACK: this isn't the best place for this to live, but if we move it somewhere else
// then we need a larger hack to hook the map change event.
var briefing = MissionBriefingOrDefault(server);
if (briefing != null)
server.SendOrderTo(conn, "Message", briefing);
}
}

View File

@@ -611,7 +611,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (!mapAvailable && map.Status == MapStatus.Available)
{
mapAvailable = true;
orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}"));
CurrentMapBecameAvailable();
}
if (panel == PanelType.Options && OptionsTabDisabled())
@@ -665,6 +665,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
}
void CurrentMapBecameAvailable()
{
orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}"));
var missionData = map.WorldActorInfo.TraitInfoOrDefault<MissionDataInfo>();
if (missionData != null && !string.IsNullOrEmpty(missionData.Briefing))
TextNotificationsManager.AddSystemLine(missionData.Briefing.Replace("\\n", "\n"));
}
void UpdateCurrentMap()
{
mapStatus = orderManager.LobbyInfo.GlobalSettings.MapStatus;
@@ -677,7 +686,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Tell the server that we have the map
mapAvailable = map.Status == MapStatus.Available;
if (mapAvailable)
orderManager.IssueOrder(Order.Command($"state {Session.ClientState.NotReady}"));
CurrentMapBecameAvailable();
// We don't have the map
else if (map.Status != MapStatus.DownloadAvailable && Game.Settings.Game.AllowDownloading)