Replace most T.Parse with T.TryParse for all user input.

This commit is contained in:
hondacrx
2017-11-05 15:21:29 -05:00
parent 8c863de8a6
commit 8ed446ae7a
40 changed files with 477 additions and 527 deletions
+4 -4
View File
@@ -47,7 +47,8 @@ namespace Game.Chat.Commands
if (string.IsNullOrEmpty(durationStr))
return false;
uint duration = uint.Parse(durationStr);
if (!uint.TryParse(durationStr, out uint duration))
return false;
string reasonStr = args.NextString("");
if (string.IsNullOrEmpty(reasonStr))
@@ -115,9 +116,8 @@ namespace Game.Chat.Commands
if (string.IsNullOrEmpty(nameOrIP))
return false;
uint duration;
string durationStr = args.NextString();
if (string.IsNullOrEmpty(durationStr) || !uint.TryParse(durationStr, out duration))
if (!uint.TryParse(durationStr, out uint duration))
return false;
string reasonStr = args.NextString("");
@@ -144,7 +144,7 @@ namespace Game.Chat.Commands
switch (Global.WorldMgr.BanAccount(mode, nameOrIP, durationStr, reasonStr, author))
{
case BanReturn.Success:
if (uint.Parse(durationStr) > 0)
if (!uint.TryParse(durationStr, out uint tempValue) || tempValue > 0)
{
if (WorldConfig.GetBoolValue(WorldCfg.ShowBanInWorld))
Global.WorldMgr.SendWorldText(CypherStrings.BanAccountYoubannedmessageWorld, author, nameOrIP, Time.secsToTimeString(Time.TimeStringToSecs(durationStr)).ToString(), reasonStr);