X Tutup
Skip to content

Commit 5c51f45

Browse files
PunkPunpchote
authored andcommitted
Silence autosave audio notification
1 parent 413aa00 commit 5c51f45

File tree

8 files changed

+17
-9
lines changed

8 files changed

+17
-9
lines changed

OpenRA.Game/Network/Order.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ public static Order FromTargetString(string order, string targetString, bool isI
269269
return new Order(order, null, false) { IsImmediate = isImmediate, TargetString = targetString };
270270
}
271271

272+
public static Order FromTargetString(string order, string targetString, bool isImmediate, uint extraData)
273+
{
274+
return new Order(order, null, false) { IsImmediate = isImmediate, TargetString = targetString, ExtraData = extraData };
275+
}
276+
272277
public static Order FromGroupedOrder(Order grouped, Actor subject)
273278
{
274279
return new Order(

OpenRA.Game/Network/UnitOrders.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ internal static void ProcessOrder(OrderManager orderManager, World world, int cl
211211

212212
case "GameSaved":
213213
foreach (var nsr in orderManager.World.WorldActor.TraitsImplementing<INotifyGameSaved>())
214-
nsr.GameSaved(orderManager.World);
214+
nsr.GameSaved(orderManager.World, order.ExtraData != 0);
215215
break;
216216

217217
case "PauseGame":

OpenRA.Game/Server/Server.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ void InterpretServerOrder(Connection conn, Order o)
10561056
Directory.CreateDirectory(baseSavePath);
10571057

10581058
GameSave.Save(Path.Combine(baseSavePath, filename));
1059-
DispatchServerOrdersToClients(Order.FromTargetString("GameSaved", filename, true));
1059+
DispatchServerOrdersToClients(Order.FromTargetString("GameSaved", filename, true, o.ExtraData));
10601060
}
10611061

10621062
break;

OpenRA.Game/Traits/TraitsInterfaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public interface IWorldLoaded { void WorldLoaded(World w, WorldRenderer wr); }
373373
public interface IPostWorldLoaded { void PostWorldLoaded(World w, WorldRenderer wr); }
374374
public interface INotifyGameLoading { void GameLoading(World w); }
375375
public interface INotifyGameLoaded { void GameLoaded(World w); }
376-
public interface INotifyGameSaved { void GameSaved(World w); }
376+
public interface INotifyGameSaved { void GameSaved(World w, bool isAutoSave); }
377377

378378
public interface IGameSaveTraitData
379379
{

OpenRA.Game/World.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ internal void OnClientDisconnected(int clientId)
562562
}
563563
}
564564

565-
public void RequestGameSave(string filename)
565+
public void RequestGameSave(string filename, bool isAutosave)
566566
{
567567
// Allow traits to save arbitrary data that will be passed back via IGameSaveTraitData.ResolveTraitData
568568
// at the end of the save restoration
@@ -580,7 +580,8 @@ public void RequestGameSave(string filename)
580580
i++;
581581
}
582582

583-
IssueOrder(Order.FromTargetString("CreateGameSave", filename, true));
583+
var extraData = isAutosave ? 1u : 0u;
584+
IssueOrder(Order.FromTargetString("CreateGameSave", filename, true, extraData));
584585
}
585586

586587
public bool Disposing;

OpenRA.Mods.Common/Traits/World/AutoSave.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void ITick.Tick(Actor self)
8080

8181
var dateTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHHmmssZ", CultureInfo.InvariantCulture);
8282
var fileName = $"{AutoSavePattern}{dateTime}{SaveFileExtension}";
83-
self.World.RequestGameSave(fileName);
83+
self.World.RequestGameSave(fileName, true);
8484
ticksUntilAutoSave = GetTicksBetweenAutosaves(self);
8585
}
8686

OpenRA.Mods.Common/Traits/World/StartGameNotification.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ void INotifyGameLoaded.GameLoaded(World world)
6464
}
6565
}
6666

67-
void INotifyGameSaved.GameSaved(World world)
67+
void INotifyGameSaved.GameSaved(World world, bool isAutosave)
6868
{
6969
if (!world.IsReplay)
7070
{
71-
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer?.Faction.InternalName);
71+
if (!isAutosave)
72+
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer?.Faction.InternalName);
73+
7274
TextNotificationsManager.AddTransientLine(null, info.SavedTextNotification);
7375
}
7476
}

OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ void Save(World world)
377377

378378
void Inner()
379379
{
380-
world.RequestGameSave(filename);
380+
world.RequestGameSave(filename, false);
381381
Ui.CloseWindow();
382382
onExit();
383383
}

0 commit comments

Comments
 (0)
X Tutup