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 -12
View File
@@ -40,11 +40,9 @@ namespace Game.Chat
// .addquest #entry'
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
string cId = handler.extractKeyFromLink(args, "Hquest");
if (string.IsNullOrEmpty(cId))
if (!uint.TryParse(cId, out uint entry))
return false;
uint entry = uint.Parse(cId);
Quest quest = Global.ObjectMgr.GetQuestTemplate(entry);
if (quest == null)
{
@@ -82,11 +80,9 @@ namespace Game.Chat
// .quest complete #entry
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
string cId = handler.extractKeyFromLink(args, "Hquest");
if (string.IsNullOrEmpty(cId))
if (!uint.TryParse(cId, out uint entry))
return false;
uint entry = uint.Parse(cId);
Quest quest = Global.ObjectMgr.GetQuestTemplate(entry);
// If player doesn't have the quest
@@ -176,11 +172,9 @@ namespace Game.Chat
// .removequest #entry'
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
string cId = handler.extractKeyFromLink(args, "Hquest");
if (string.IsNullOrEmpty(cId))
if (!uint.TryParse(cId, out uint entry))
return false;
uint entry = uint.Parse(cId);
Quest quest = Global.ObjectMgr.GetQuestTemplate(entry);
if (quest == null)
{
@@ -229,11 +223,9 @@ namespace Game.Chat
// .quest reward #entry
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
string cId = handler.extractKeyFromLink(args, "Hquest");
if (string.IsNullOrEmpty(cId))
if (!uint.TryParse(cId, out uint entry))
return false;
uint entry = uint.Parse(cId);
Quest quest = Global.ObjectMgr.GetQuestTemplate(entry);
// If player doesn't have the quest