diff --git a/Maple2.Database/Storage/Game/GameStorage.User.cs b/Maple2.Database/Storage/Game/GameStorage.User.cs index 1500226bc..03e68ac66 100644 --- a/Maple2.Database/Storage/Game/GameStorage.User.cs +++ b/Maple2.Database/Storage/Game/GameStorage.User.cs @@ -70,6 +70,10 @@ public bool UpdateMachineId(long accountId, Guid machineId) { return (model, characters); } + public void SetAllCharacterToOffline() { + Context.Database.ExecuteSqlRaw("UPDATE `character` SET Channel = -1"); + } + // If accountId is specified, only characters for the account will be returned. public Character? GetCharacter(long characterId, long accountId = -1) { if (accountId < 0) { diff --git a/Maple2.Server.World/WorldServer.cs b/Maple2.Server.World/WorldServer.cs index 5b278487e..f1db9ca0f 100644 --- a/Maple2.Server.World/WorldServer.cs +++ b/Maple2.Server.World/WorldServer.cs @@ -45,6 +45,8 @@ public WorldServer(GameStorage gameStorage, ChannelClientLookup channelClients, scheduler.Start(); memoryStringBoards = []; + SetAllCharacterToOffline(); + StartDailyReset(); StartWorldEvents(); ScheduleGameEvents(); @@ -55,6 +57,11 @@ public WorldServer(GameStorage gameStorage, ChannelClientLookup channelClients, heartbeatThread.Start(); } + private void SetAllCharacterToOffline() { + using GameStorage.Request db = gameStorage.Context(); + db.SetAllCharacterToOffline(); + } + private void Heartbeat() { while (!tokenSource.Token.IsCancellationRequested) { try {