Skip to content

Commit f4da136

Browse files
author
尧杰 曾
committed
Remove placeholder
1 parent 2fcc633 commit f4da136

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

CDK/DatabaseManager.cs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public RedeemCDKResult RedeemCDK(UnturnedPlayer player, string CDK)
8585
{
8686
return RedeemCDKResult.KeyNotValid;
8787
}
88-
else
89-
{
88+
//else
89+
//{
9090
if (cdkdata.Items.Length != 0 && cdkdata.Amount.Length == 0)
9191
{
9292

@@ -103,18 +103,10 @@ public RedeemCDKResult RedeemCDK(UnturnedPlayer player, string CDK)
103103

104104
for (int i = 0; i < amount.Length; i++)
105105
{
106-
//try
107-
//{
108106
if (!player.GiveItem(Convert.ToUInt16(items[i]), Convert.ToByte(amount[i])))
109107
{
110108
UnturnedChat.Say(player, Main.Instance.Translate("items_give_fail"), UnityEngine.Color.red);
111109
}
112-
//}
113-
//catch(Exception ex)
114-
//{
115-
// Logger.LogException(ex);
116-
// UnturnedChat.Say(player, Main.Instance.Translate("cdk_config_error"), UnityEngine.Color.red);
117-
//}
118110
}
119111
}
120112

@@ -171,7 +163,7 @@ public RedeemCDKResult RedeemCDK(UnturnedPlayer player, string CDK)
171163
SaveLogToDB(new LogData(CDK, player.CSteamID, DateTime.Now, cdkdata.ValidUntil, cdkdata.GrantPermissionGroup, cdkdata.UsePermissionSync));
172164
IncreaseRedeemedTime(CDK);
173165
return RedeemCDKResult.Success;
174-
}
166+
//}
175167
}
176168
else if (logdata != null && cdkdata.Renew)
177169
{
@@ -226,17 +218,17 @@ internal void CheckValid(UnturnedPlayer player)
226218

227219
private CDKData BuildCDKData(MySqlDataReader reader)
228220
{
229-
var cid = reader.GetString(12);
221+
var cid = Convert.ToUInt64(reader[12]);
230222
CSteamID owner = CSteamID.Nil;
231-
if (cid != string.Empty)
223+
if (cid != 0)
232224
{
233-
owner = new CSteamID(Convert.ToUInt64(cid));
225+
owner = new CSteamID(cid);
234226
}
235-
return new CDKData(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetUInt16(3), reader.GetUInt16(4), reader.GetDecimal(6), reader.GetInt32(5), reader.GetString(7), reader.GetInt32(9), reader.GetInt32(8), reader.GetDateTime(10), owner, reader.GetBoolean(11), reader.GetBoolean(13));
227+
return new CDKData(reader.GetString(0), Convert.ToString(reader["Items"]), Convert.ToString(reader["Amount"]), Convert.ToUInt16(reader["Vehicle"]), Convert.ToUInt16(reader["Experience"]), Convert.ToDecimal(reader["Money"]), Convert.ToInt32(reader["Reputation"]), Convert.ToString(reader[7]), reader.GetInt32(9), reader.GetInt32(8), reader.GetDateTime(10), owner, reader.GetBoolean(11), reader.GetBoolean(13));
236228
}
237229
private LogData BuildLogData(MySqlDataReader reader)
238230
{
239-
return new LogData(reader.GetString(0), new CSteamID(Convert.ToUInt64(reader.GetUInt64(1))), reader.GetDateTime(2), reader.GetDateTime(3),reader.GetString(4),reader.GetBoolean(5));
231+
return new LogData(reader.GetString(0), new CSteamID(Convert.ToUInt64(reader[1])), reader.GetDateTime(2), reader.GetDateTime(3),Convert.ToString(reader[4]),reader.GetBoolean(5));
240232
}
241233

242234
public CDKData GetCDKData(string cdk)
@@ -375,14 +367,14 @@ internal void CheckSchema() // intial mysql table
375367

376368
if (cdk == null)
377369
ExecuteQuery(false,
378-
$"CREATE TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` (`CDK` varchar(32) NOT NULL,`Items` varchar(32) NOT NULL Default '0', `Amount` varchar(32) NOT NULL DEFAULT '0', `Vehicle` int(16) NOT NULL DEFAULT '0', `Experience` int(32) NOT NULL DEFAULT '0', `Reputation` int NOT NULL DEFAULT '0' , `Money` decimal(16,2) NOT NULL DEFAULT '0', `GrantPermissionGroup` varchar(32) NOT NULL DEFAULT '' , `MaxRedeem` int(32) NOT NULL DEFAULT '1', `RedeemedTimes` int(6) NOT NULL DEFAULT '0', `ValidUntil` datetime(6) NOT NULL DEFAULT '{DateTime.MaxValue}', `EnableRenew` BOOLEAN NOT NULL DEFAULT '0', `Owner` varchar(32) NOT NULL DEFAULT '' , `UsePermissionSync` BOOLEAN NOT NULL DEFAULT '0',PRIMARY KEY (`CDK`))");
370+
$"CREATE TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` (`CDK` varchar(32) NOT NULL,`Items` varchar(32) , `Amount` varchar(32), `Vehicle` int(16) UNSIGNED, `Experience` int(32), `Reputation` int , `Money` decimal(16,2), `GrantPermissionGroup` varchar(32), `MaxRedeem` int(32) NOT NULL DEFAULT '1', `RedeemedTimes` int(6) NOT NULL DEFAULT '0', `ValidUntil` datetime(6) NOT NULL DEFAULT '{DateTime.MaxValue}', `EnableRenew` BOOLEAN NOT NULL DEFAULT '0', `Owner` BIGINT, `UsePermissionSync` BOOLEAN NOT NULL DEFAULT '0',PRIMARY KEY (`CDK`))");
379371

380372
var log = ExecuteQuery(true,
381373
$"show tables like '{Main.Instance.Configuration.Instance.DatabaseRedeemLogTableName}'");
382374

383375
if (log == null)
384376
ExecuteQuery(false,
385-
$"CREATE TABLE `{Main.Instance.Configuration.Instance.DatabaseRedeemLogTableName}` (`CDK` varchar(32) NOT NULL, `SteamID` varchar(32) NOT NULL, `Redeemed Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `ValidUntil` datetime(6) NOT NULL, `GrantPermissionGroup` VARCHAR(32) NOT NULL DEFAULT '{string.Empty}', `UsePermissionSync` BOOLEAN NOT NULL DEFAULT '0')");
377+
$"CREATE TABLE `{Main.Instance.Configuration.Instance.DatabaseRedeemLogTableName}` (`CDK` varchar(32) NOT NULL, `SteamID` varchar(32) NOT NULL, `Redeemed Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `ValidUntil` datetime(6) NOT NULL, `GrantPermissionGroup` VARCHAR(32), `UsePermissionSync` BOOLEAN NOT NULL DEFAULT '0')");
386378
if(Main.Instance.Configuration.Instance.MySQLTableVer == 1)
387379
{
388380
ExecuteQuery(true,
@@ -392,6 +384,18 @@ internal void CheckSchema() // intial mysql table
392384
Main.Instance.Configuration.Instance.MySQLTableVer = 2;
393385
Main.Instance.Configuration.Save();
394386
}
387+
if(Main.Instance.Configuration.Instance.MySQLTableVer == 2)
388+
{
389+
ExecuteQuery(true, $"ALTER TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` MODIFY `Items` VARCHAR(32)");
390+
ExecuteQuery(true, $"ALTER TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` MODIFY `Amount` VARCHAR(32)");
391+
ExecuteQuery(true, $"ALTER TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` MODIFY `Vehicle` INT(16) UNSIGNED");
392+
ExecuteQuery(true, $"ALTER TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` MODIFY `Experience` INT(32) ");
393+
ExecuteQuery(true, $"ALTER TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` MODIFY `Reputation` INT ");
394+
ExecuteQuery(true, $"ALTER TABLE `{Main.Instance.Configuration.Instance.DatabaseCDKTableName}` MODIFY `Money` decimal(16,2)");
395+
ExecuteQuery(true, $"ALTER TABLE `{Main.Instance.Configuration.Instance.DatabaseRedeemLogTableName}` MODIFY `GrantPermissionGroup` VARCHAR(32)");
396+
Main.Instance.Configuration.Instance.MySQLTableVer = 3;
397+
Main.Instance.Configuration.Save();
398+
}
395399
}
396400

397401
private MySqlConnection CreateConnection()

CDK/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
3333
//通过使用 "*",如下所示:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.2.3.0")]
36-
[assembly: AssemblyFileVersion("3.2.3.0")]
35+
[assembly: AssemblyVersion("3.2.4.0")]
36+
[assembly: AssemblyFileVersion("3.2.4.0")]

0 commit comments

Comments
 (0)