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
+6 -4
View File
@@ -100,7 +100,9 @@ namespace Game.Chat
Global.WorldMgr.LoadDBAllowedSecurityLevel();
break;
default:
int value = int.Parse(paramStr);
if (!int.TryParse(paramStr, out int value))
return false;
if (value < 0)
Global.WorldMgr.SetPlayerSecurityLimit((AccountTypes)(-value));
else
@@ -148,7 +150,8 @@ namespace Game.Chat
static bool ParseExitCode(string exitCodeStr, out int exitCode)
{
exitCode = int.Parse(exitCodeStr);
if (!int.TryParse(exitCodeStr, out exitCode))
return false;
// Handle atoi() errors
if (exitCode == 0 && (exitCodeStr[0] != '0' || (exitCodeStr.Length > 1 && exitCodeStr[1] != '\0')))
@@ -317,8 +320,7 @@ namespace Game.Chat
if (newTimeStr.IsEmpty())
return false;
int newTime = int.Parse(newTimeStr);
if (newTime < 0)
if (!int.TryParse(newTimeStr, out int newTime) || newTime < 0)
return false;
//Global.WorldMgr.SetRecordDiffInterval(newTime);