-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using ProtoBuf; | ||
|
||
namespace CSM.Commands.Data.Internal | ||
{ | ||
/// <summary> | ||
/// Requests a world transfer/sync, only sent by clients | ||
/// </summary> | ||
|
||
[ProtoContract] | ||
class RequestWorldTransferCommand : CommandBase | ||
{ | ||
|
||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Commands/Handler/Internal/RequestWorldTransferHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using CSM.Commands.Data.Internal; | ||
using CSM.Helpers; | ||
using CSM.Networking; | ||
using ColossalFramework.Threading; | ||
using ColossalFramework.UI; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using CSM.Networking.Status; | ||
|
||
namespace CSM.Commands.Handler.Internal | ||
{ | ||
|
||
class RequestWorldTransferHandler : CommandHandler<RequestWorldTransferCommand> | ||
{ | ||
protected override void Handle(RequestWorldTransferCommand command) | ||
{ | ||
//pause game | ||
MultiplayerManager.Instance.GameBlocked = true; | ||
SimulationManager.instance.SimulationPaused = true; | ||
//saving world | ||
SaveHelpers.SaveServerLevel(); | ||
|
||
new Thread(() => | ||
{ | ||
while (SaveHelpers.IsSaving()) | ||
{ | ||
Thread.Sleep(100); | ||
} | ||
//send the world to the client | ||
Command.SendToClient(MultiplayerManager.Instance.CurrentServer.ConnectedPlayers[command.SenderId], new WorldTransferCommand | ||
{ | ||
World = SaveHelpers.GetWorldFile() | ||
}); | ||
|
||
MultiplayerManager.Instance.CurrentServer.ConnectedPlayers[command.SenderId].Status = ClientStatus.Loading; | ||
}).Start(); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters