Skip to content

Commit 2c22624

Browse files
committed
Merge pull request #12 from UTengine/CharacterLogoutSaveFix
Fixing character logout save
2 parents 1a757fe + 73b6a81 commit 2c22624

26 files changed

+4241
-2
lines changed

import.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ function RunMigrationScripts {
106106
function RunMigrationScriptsAndGenerateDiffs {
107107
$scripts = GetMigrationScripts
108108
MessageInfo "`n`n### Running $($scripts.Count) migration scripts and generate diffs... ###"
109-
$targetDirs = ".\src\schema\*", ".\src\data\*", ".\src\procedure\*"
109+
$targetDirs = ".\src\schema\", ".\src\data\", ".\src\procedure\"
110110
$tempUniqueCommitMessage = "####" + (New-Guid)
111111

112112
git reset # unstage all changes
113113
git clean -f .\src\migration\*.diff # cleanup previous untracked diff files
114114
foreach ($script In $scripts) {
115115
Message $script.FullName
116116
InvokeSqlScript -script_path $script.FullName
117-
.\export.ps1 -server_name $server_name -db_name $db_name -quiet $true
117+
.\export.ps1 -server_name $server_name -db_name $db_name -apply_format $false -quiet $true
118118
git add $targetDirs
119119
$diffOutputFile = $script.FullName + ".diff"
120120
# Note that powershell messes up with the output and corrupts the patch, hence we use cmd here.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- Note that normally we would need to recreate the table if we want to perserve the order of columns,
2+
-- as there is no way of sorting them. Worth noting that the sql engine doesn't care much about the order when
3+
-- explictly querying columns from tables. However since the columns we modify are the last ones, we can
4+
-- take a shortcut by droping and then adding them in the right order.
5+
6+
-- No longer need default value constraints for it, since it is fixed length binary column.
7+
ALTER TABLE USERDATA DROP CONSTRAINT DF_USERDATA_strSkill;
8+
GO
9+
10+
ALTER TABLE USERDATA ADD
11+
bySkill binary(10) NULL,
12+
byItem binary(400) NULL,
13+
bySerial binary(400) NULL;
14+
GO
15+
16+
-- Implicit conversion from data type varchar to binary is not allowed.
17+
UPDATE USERDATA SET bySkill = CONVERT(binary, strSkill);
18+
19+
-- Note that there is no need to convert these two below to binary, since they were already binary
20+
-- and someone forgot or didn't bother to rename them.
21+
UPDATE USERDATA SET byItem = strItem;
22+
UPDATE USERDATA SET bySerial = strSerial;
23+
GO
24+
25+
-- Done reworking these columns? let's get ride of them.
26+
ALTER TABLE USERDATA DROP COLUMN strSkill;
27+
ALTER TABLE USERDATA DROP COLUMN strItem;
28+
ALTER TABLE USERDATA DROP COLUMN strSerial;
29+
GO
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/src/schema/USERDATA.sql b/src/schema/USERDATA.sql
2+
index 9b40bd9..53d47b4 100644
3+
--- a/src/schema/USERDATA.sql
4+
+++ b/src/schema/USERDATA.sql
5+
@@ -34,9 +34,9 @@ CREATE TABLE [dbo].[USERDATA](
6+
[PZ] [int] NOT NULL,
7+
[PY] [int] NOT NULL,
8+
[dwTime] [int] NOT NULL,
9+
- [strSkill] [varchar](10) NULL,
10+
- [strItem] [binary](400) NULL,
11+
- [strSerial] [binary](400) NULL,
12+
+ [bySkill] [binary](10) NULL,
13+
+ [byItem] [binary](400) NULL,
14+
+ [bySerial] [binary](400) NULL,
15+
CONSTRAINT [PK_USERDATA] PRIMARY KEY CLUSTERED
16+
(
17+
[strUserId] ASC
18+
@@ -106,5 +106,3 @@ ALTER TABLE [dbo].[USERDATA] ADD CONSTRAINT [DF_USERDATA_PY] DEFAULT ((0)) FOR
19+
GO
20+
ALTER TABLE [dbo].[USERDATA] ADD CONSTRAINT [DF_USERDATA_dwTime] DEFAULT ((0)) FOR [dwTime]
21+
GO
22+
-ALTER TABLE [dbo].[USERDATA] ADD CONSTRAINT [DF_USERDATA_strSkill] DEFAULT (0x00) FOR [strSkill]
23+
-GO
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
SET ANSI_NULLS OFF
2+
GO
3+
SET QUOTED_IDENTIFIER OFF
4+
GO
5+
ALTER PROCEDURE [dbo].[UPDATE_USER_DATA]
6+
@id varchar(21),
7+
@Nation tinyint,
8+
@Race tinyint,
9+
@Class smallint,
10+
@HairColor tinyint,
11+
@Rank tinyint,
12+
@Title tinyint,
13+
@Level tinyint,
14+
@Exp int,
15+
@Loyalty int,
16+
@Face tinyint,
17+
@City tinyint,
18+
@Knights smallint,
19+
@Fame tinyint,
20+
@Hp smallint,
21+
@Mp smallint,
22+
@Sp smallint,
23+
@Str tinyint,
24+
@Sta tinyint,
25+
@Dex tinyint,
26+
@Intel tinyint,
27+
@Cha tinyint,
28+
@Authority tinyint,
29+
@Points tinyint,
30+
@Gold int,
31+
@Zone tinyint,
32+
@Bind smallint,
33+
@PX int,
34+
@PZ int,
35+
@PY int,
36+
@dwTime int,
37+
@bySkill binary(10),
38+
@byItem binary(400),
39+
@bySerial binary(400)
40+
AS
41+
42+
DECLARE @KnightsIndex smallint
43+
44+
IF @Zone > 2 -- battle zone user
45+
BEGIN
46+
SELECT @KnightsIndex = Knights FROM USERDATA WHERE strUserId = @id
47+
IF @KnightsIndex = -1 -- expel user
48+
BEGIN
49+
SET @Knights = 0
50+
SET @Fame = 0
51+
END
52+
END
53+
54+
UPDATE USERDATA
55+
SET
56+
Nation = @Nation,
57+
Race = @Race,
58+
[Class] = @Class,
59+
HairColor = @HairColor,
60+
Rank = @Rank,
61+
Title = @Title,
62+
[Level] = @Level,
63+
[Exp] = @Exp,
64+
Loyalty = @Loyalty,
65+
Face = @Face,
66+
City = @City,
67+
Knights = @Knights,
68+
Fame = @Fame,
69+
Hp = @Hp,
70+
Mp = @Mp,
71+
Sp = @Sp,
72+
Strong = @Str,
73+
Sta = @Sta,
74+
Dex = @Dex,
75+
Intel = @Intel,
76+
Cha = @Cha,
77+
Authority = @Authority,
78+
Points = @Points,
79+
Gold = @Gold,
80+
[Zone] = @Zone,
81+
Bind = @Bind,
82+
PX = @PX,
83+
PZ = @PZ,
84+
PY = @PY,
85+
dwTime = @dwTime,
86+
bySkill = @bySkill,
87+
byItem = @byItem,
88+
bySerial = @bySerial
89+
WHERE strUserId = @id
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/src/procedure/UPDATE_USER_DATA.sql b/src/procedure/UPDATE_USER_DATA.sql
2+
index dcb8da3..5279adf 100644
3+
--- a/src/procedure/UPDATE_USER_DATA.sql
4+
+++ b/src/procedure/UPDATE_USER_DATA.sql
5+
@@ -34,9 +34,9 @@ CREATE PROCEDURE [dbo].[UPDATE_USER_DATA]
6+
@PZ int,
7+
@PY int,
8+
@dwTime int,
9+
- @strSkill varchar(20),
10+
- @strItem binary(400),
11+
- @strSerial binary(400)
12+
+ @bySkill binary(10),
13+
+ @byItem binary(400),
14+
+ @bySerial binary(400)
15+
AS
16+
17+
DECLARE @KnightsIndex smallint
18+
@@ -83,9 +83,9 @@ SET
19+
PZ = @PZ,
20+
PY = @PY,
21+
dwTime = @dwTime,
22+
- strSkill = @strSkill,
23+
- strItem = @strItem,
24+
- strSerial = @strSerial
25+
+ bySkill = @bySkill,
26+
+ byItem = @byItem,
27+
+ bySerial = @bySerial
28+
WHERE strUserId = @id
29+
30+
GO
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
SET ANSI_NULLS OFF
2+
GO
3+
SET QUOTED_IDENTIFIER ON
4+
GO
5+
-- Scripted by Samma
6+
-- 2002.01.18
7+
8+
ALTER PROCEDURE [dbo].[LOAD_CHAR_INFO]
9+
@CharId char(21),
10+
@nRet smallint OUTPUT
11+
AS
12+
13+
SELECT @nRet = COUNT(strUserId) FROM USERDATA WHERE strUserId = @CharId
14+
IF @nRet = 0
15+
RETURN
16+
17+
SELECT
18+
Race,
19+
[Class],
20+
HairColor,
21+
[Level],
22+
Face,
23+
Zone,
24+
byItem
25+
FROM USERDATA WHERE strUserID = @CharId
26+
27+
SET @nRet = 1
28+
RETURN
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/procedure/LOAD_CHAR_INFO.sql b/src/procedure/LOAD_CHAR_INFO.sql
2+
index 84cd4f0..6e70027 100644
3+
--- a/src/procedure/LOAD_CHAR_INFO.sql
4+
+++ b/src/procedure/LOAD_CHAR_INFO.sql
5+
@@ -21,7 +21,7 @@ IF @nRet = 0
6+
[Level],
7+
Face,
8+
Zone,
9+
- strItem
10+
+ byItem
11+
FROM USERDATA WHERE strUserID = @CharId
12+
13+
SET @nRet = 1
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
SET ANSI_NULLS ON
2+
GO
3+
SET QUOTED_IDENTIFIER OFF
4+
GO
5+
6+
7+
ALTER PROCEDURE [dbo].[LOAD_USER_DATA]
8+
@id char(21),
9+
@nRet smallint OUTPUT
10+
AS
11+
12+
SET @nRet = 0
13+
14+
SELECT @nRet = COUNT(strUserId) FROM USERDATA WHERE strUserId = @id
15+
IF @nRet = 0
16+
RETURN
17+
18+
SELECT
19+
Nation,
20+
Race,
21+
[Class],
22+
HairColor,
23+
Rank,
24+
Title,
25+
[Level],
26+
[Exp],
27+
Loyalty,
28+
Face,
29+
City,
30+
Knights,
31+
Fame,
32+
Hp,
33+
Mp,
34+
Sp,
35+
Strong,
36+
Sta,
37+
Dex,
38+
Intel,
39+
Cha,
40+
Authority,
41+
Points,
42+
Gold,
43+
[Zone],
44+
Bind,
45+
PX,
46+
PZ,
47+
PY,
48+
dwTime,
49+
bySkill,
50+
byItem,
51+
bySerial
52+
FROM USERDATA WHERE strUserId = @id
53+
54+
SET @nRet = 1
55+
RETURN
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/src/procedure/LOAD_USER_DATA.sql b/src/procedure/LOAD_USER_DATA.sql
2+
index 4a33232..11a266e 100644
3+
--- a/src/procedure/LOAD_USER_DATA.sql
4+
+++ b/src/procedure/LOAD_USER_DATA.sql
5+
@@ -46,9 +46,9 @@ IF @nRet = 0
6+
PZ,
7+
PY,
8+
dwTime,
9+
- strSkill,
10+
- strItem,
11+
- strSerial
12+
+ bySkill,
13+
+ byItem,
14+
+ bySerial
15+
FROM USERDATA WHERE strUserId = @id
16+
17+
SET @nRet = 1

0 commit comments

Comments
 (0)