@@ -32,10 +32,10 @@ DROP PROCEDURE IF EXISTS [dbo].[SelectBanked]
3232DROP PROCEDURE IF EXISTS [dbo].[SelectEquipped]
3333DROP PROCEDURE IF EXISTS [dbo].[SelectInventory]
3434DROP PROCEDURE IF EXISTS [dbo].[SelectDiscoveredMaps]
35- DROP PROCEDURE IF EXISTS [dbo].[SelectDeBuffsCheck]
3635DROP PROCEDURE IF EXISTS [dbo].[SelectDeBuffs]
37- DROP PROCEDURE IF EXISTS [dbo].[SelectBuffsCheck]
3836DROP PROCEDURE IF EXISTS [dbo].[SelectBuffs]
37+ DROP PROCEDURE IF EXISTS [dbo].[PlayerDeBuffSync]
38+ DROP PROCEDURE IF EXISTS [dbo].[PlayerBuffSync]
3939DROP PROCEDURE IF EXISTS [dbo].[PlayerSecurity]
4040DROP PROCEDURE IF EXISTS [dbo].[PlayerSaveSpells]
4141DROP PROCEDURE IF EXISTS [dbo].[PlayerSaveSkills]
@@ -46,16 +46,12 @@ DROP PROCEDURE IF EXISTS [dbo].[PlayerCreation]
4646DROP PROCEDURE IF EXISTS [dbo].[AccountLockoutCount]
4747DROP PROCEDURE IF EXISTS [dbo].[PasswordSave]
4848DROP PROCEDURE IF EXISTS [dbo].[InsertQuests]
49- DROP PROCEDURE IF EXISTS [dbo].[InsertDeBuff]
50- DROP PROCEDURE IF EXISTS [dbo].[InsertBuff]
5149DROP PROCEDURE IF EXISTS [dbo].[IgnoredSave]
5250DROP PROCEDURE IF EXISTS [dbo].[FoundMap]
53- DROP PROCEDURE IF EXISTS [dbo].[DeBuffSave]
5451DROP PROCEDURE IF EXISTS [dbo].[CheckIfPlayerSerialExists]
5552DROP PROCEDURE IF EXISTS [dbo].[CheckIfPlayerHashExists]
5653DROP PROCEDURE IF EXISTS [dbo].[CheckIfPlayerExists]
5754DROP PROCEDURE IF EXISTS [dbo].[LoadItemsToCache]
58- DROP PROCEDURE IF EXISTS [dbo].[BuffSave]
5955DROP PROCEDURE IF EXISTS [dbo].[AddLegendMark]
6056DROP PROCEDURE IF EXISTS [dbo].[ItemUpsert]
6157DROP PROCEDURE IF EXISTS [dbo].[ItemMassDelete]
@@ -198,15 +194,13 @@ CREATE TABLE PlayersDiscoveredMaps
198194
199195CREATE TABLE PlayersBuffs
200196(
201- [BuffId] INT NOT NULL PRIMARY KEY ,
202197 [Serial] BIGINT FOREIGN KEY REFERENCES Players(Serial ),
203198 [Name] VARCHAR (30 ) NULL ,
204199 [TimeLeft] INT NOT NULL DEFAULT 0
205200)
206201
207202CREATE TABLE PlayersDebuffs
208203(
209- [DebuffId] INT NOT NULL PRIMARY KEY ,
210204 [Serial] BIGINT FOREIGN KEY REFERENCES Players(Serial ),
211205 [Name] VARCHAR (30 ) NULL ,
212206 [TimeLeft] INT NOT NULL DEFAULT 0
@@ -747,26 +741,6 @@ BEGIN
747741END
748742GO
749743
750- -- BuffSave
751- SET ANSI_NULLS ON
752- GO
753- SET QUOTED_IDENTIFIER ON
754- GO
755- CREATE PROCEDURE [dbo].[BuffSave]
756- @Buffs dbo .BuffType READONLY
757- AS
758- BEGIN
759- SET NOCOUNT ON ;
760-
761- UPDATE target
762- SET target .[Name] = source.[Name],
763- target .[TimeLeft] = source.[TimeLeft]
764- FROM [ZolianPlayers].[dbo].[PlayersBuffs] AS target
765- INNER JOIN @Buffs AS source
766- ON target .Serial = source .Serial AND target .Name = source .Name ;
767- END
768- GO
769-
770744-- LoadItemsToCache
771745SET ANSI_NULLS ON
772746GO
@@ -820,26 +794,6 @@ BEGIN
820794END
821795GO
822796
823- -- DeBuffSave
824- SET ANSI_NULLS ON
825- GO
826- SET QUOTED_IDENTIFIER ON
827- GO
828- CREATE PROCEDURE [dbo].[DeBuffSave]
829- @Debuffs dbo .DebuffType READONLY
830- AS
831- BEGIN
832- SET NOCOUNT ON ;
833-
834- UPDATE target
835- SET target .[Name] = source.[Name],
836- target .[TimeLeft] = source.[TimeLeft]
837- FROM [ZolianPlayers].[dbo].[PlayersDebuffs] AS target
838- INNER JOIN @Debuffs AS source
839- ON target .Serial = source .Serial AND target .Name = source .Name ;
840- END
841- GO
842-
843797-- FoundMap
844798SET ANSI_NULLS ON
845799GO
@@ -870,36 +824,6 @@ BEGIN
870824END
871825GO
872826
873- -- InsertBuff
874- SET ANSI_NULLS ON
875- GO
876- SET QUOTED_IDENTIFIER ON
877- GO
878- CREATE PROCEDURE [dbo].[InsertBuff]
879- @BuffId INT , @Serial BIGINT , @Name VARCHAR (30 ), @TimeLeft INT
880- AS
881- BEGIN
882- SET NOCOUNT ON ;
883- INSERT INTO [ZolianPlayers].[dbo].[PlayersBuffs] ([BuffId], [Serial], [Name], [TimeLeft])
884- VALUES (@BuffId, @Serial, @Name, @TimeLeft);
885- END
886- GO
887-
888- -- InsertDeBuff
889- SET ANSI_NULLS ON
890- GO
891- SET QUOTED_IDENTIFIER ON
892- GO
893- CREATE PROCEDURE [dbo].[InsertDeBuff]
894- @DebuffId INT , @Serial BIGINT , @Name VARCHAR (30 ), @TimeLeft INT
895- AS
896- BEGIN
897- SET NOCOUNT ON ;
898- INSERT INTO [ZolianPlayers].[dbo].[PlayersDeBuffs] ([DebuffId], [Serial], [Name], [TimeLeft])
899- VALUES (@DebuffId, @Serial, @Name, @TimeLeft);
900- END
901- GO
902-
903827-- InsertQuests
904828SET ANSI_NULLS ON
905829GO
@@ -1343,55 +1267,109 @@ BEGIN
13431267END
13441268GO
13451269
1346- -- SelectBuffs
1270+ -- PlayerBuffSync
13471271SET ANSI_NULLS ON
13481272GO
13491273SET QUOTED_IDENTIFIER ON
13501274GO
1351- CREATE PROCEDURE [dbo].[SelectBuffs] @Serial BIGINT
1275+ CREATE OR ALTER PROCEDURE dbo .PlayerBuffSync
1276+ (
1277+ @Serial BIGINT ,
1278+ @Buffs dbo .BuffType READONLY
1279+ )
13521280AS
13531281BEGIN
1354- SET NOCOUNT ON ;
1355- SELECT * FROM ZolianPlayers .dbo .PlayersBuffs WHERE Serial = @Serial
1356- END
1282+ SET NOCOUNT ON ;
1283+ SET XACT_ABORT ON ;
1284+
1285+ ;WITH SourceRows AS
1286+ (
1287+ SELECT
1288+ @Serial AS Serial ,
1289+ b.[Name],
1290+ b .TimeLeft
1291+ FROM @Buffs b
1292+ WHERE b .Serial = @Serial
1293+ )
1294+ MERGE dbo .PlayersBuffs WITH (HOLDLOCK) AS t
1295+ USING SourceRows AS s
1296+ ON t .Serial = s .Serial
1297+ AND t.[Name] = s.[Name]
1298+ WHEN MATCHED THEN
1299+ UPDATE SET
1300+ t .TimeLeft = s .TimeLeft
1301+ WHEN NOT MATCHED BY TARGET THEN
1302+ INSERT (Serial , [Name], TimeLeft)
1303+ VALUES (s .Serial , s.[Name], s .TimeLeft )
1304+ WHEN NOT MATCHED BY SOURCE
1305+ AND t .Serial = @Serial
1306+ THEN DELETE ;
1307+ END ;
13571308GO
13581309
1359- -- SelectBuffsCheck
1310+ -- PlayerDeBuffSync
13601311SET ANSI_NULLS ON
13611312GO
13621313SET QUOTED_IDENTIFIER ON
13631314GO
1364- CREATE PROCEDURE [dbo].[SelectBuffsCheck] @Serial BIGINT , @Name VARCHAR (30 )
1315+ CREATE OR ALTER PROCEDURE dbo .PlayerDeBuffSync
1316+ (
1317+ @Serial BIGINT ,
1318+ @Debuffs dbo .DebuffType READONLY
1319+ )
13651320AS
13661321BEGIN
1367- SET NOCOUNT ON ;
1368- SELECT * FROM ZolianPlayers .dbo .PlayersBuffs WHERE Serial = @Serial AND Name = @Name
1369- END
1322+ SET NOCOUNT ON ;
1323+ SET XACT_ABORT ON ;
1324+
1325+ ;WITH SourceRows AS
1326+ (
1327+ SELECT
1328+ @Serial AS Serial ,
1329+ b.[Name],
1330+ b .TimeLeft
1331+ FROM @Debuffs b
1332+ WHERE b .Serial = @Serial
1333+ )
1334+ MERGE dbo .PlayersDebuffs WITH (HOLDLOCK) AS t
1335+ USING SourceRows AS s
1336+ ON t .Serial = s .Serial
1337+ AND t.[Name] = s.[Name]
1338+ WHEN MATCHED THEN
1339+ UPDATE SET
1340+ t .TimeLeft = s .TimeLeft
1341+ WHEN NOT MATCHED BY TARGET THEN
1342+ INSERT (Serial , [Name], TimeLeft)
1343+ VALUES (s .Serial , s.[Name], s .TimeLeft )
1344+ WHEN NOT MATCHED BY SOURCE
1345+ AND t .Serial = @Serial
1346+ THEN DELETE ;
1347+ END ;
13701348GO
13711349
1372- -- SelectDeBuffs
1350+ -- SelectBuffs
13731351SET ANSI_NULLS ON
13741352GO
13751353SET QUOTED_IDENTIFIER ON
13761354GO
1377- CREATE PROCEDURE [dbo].[SelectDeBuffs ] @Serial BIGINT
1355+ CREATE PROCEDURE [dbo].[SelectBuffs ] @Serial BIGINT
13781356AS
13791357BEGIN
13801358 SET NOCOUNT ON ;
1381- SELECT * FROM ZolianPlayers .dbo .PlayersDebuffs WHERE Serial = @Serial
1359+ SELECT * FROM ZolianPlayers .dbo .PlayersBuffs WHERE Serial = @Serial
13821360END
13831361GO
13841362
1385- -- SelectDeBuffsCheck
1363+ -- SelectDeBuffs
13861364SET ANSI_NULLS ON
13871365GO
13881366SET QUOTED_IDENTIFIER ON
13891367GO
1390- CREATE PROCEDURE [dbo].[SelectDeBuffsCheck ] @Serial BIGINT , @Name VARCHAR ( 30 )
1368+ CREATE PROCEDURE [dbo].[SelectDeBuffs ] @Serial BIGINT
13911369AS
13921370BEGIN
13931371 SET NOCOUNT ON ;
1394- SELECT * FROM ZolianPlayers .dbo .PlayersDebuffs WHERE Serial = @Serial AND Name = @Name
1372+ SELECT * FROM ZolianPlayers .dbo .PlayersDebuffs WHERE Serial = @Serial
13951373END
13961374GO
13971375
0 commit comments