Bug in BodyTable, Bodies with an ID over 1000 we not being properly read.
Using Enum.TryParse where applicable
This commit is contained in:
parent
26899493c0
commit
b9f0138b08
5 changed files with 30 additions and 45 deletions
|
|
@ -45,7 +45,7 @@ namespace Server
|
|||
{
|
||||
using ( StreamReader ip = new StreamReader( "Data/bodyTable.cfg" ) )
|
||||
{
|
||||
m_Types = new BodyType[1000];
|
||||
m_Types = new BodyType[0x1000];
|
||||
|
||||
string line;
|
||||
|
||||
|
|
@ -56,15 +56,14 @@ namespace Server
|
|||
|
||||
string[] split = line.Split( '\t' );
|
||||
|
||||
try
|
||||
{
|
||||
int bodyID = int.Parse( split[0] );
|
||||
BodyType type = (BodyType)Enum.Parse( typeof( BodyType ), split[1], true );
|
||||
BodyType type;
|
||||
int bodyID;
|
||||
|
||||
if ( bodyID >= 0 && bodyID < m_Types.Length )
|
||||
m_Types[bodyID] = type;
|
||||
if( int.TryParse( split[0], out bodyID ) && Enum.TryParse( split[1], true, out type ) && bodyID >= 0 && bodyID < m_Types.Length )
|
||||
{
|
||||
m_Types[bodyID] = type;
|
||||
}
|
||||
catch
|
||||
else
|
||||
{
|
||||
Console.WriteLine( "Warning: Invalid bodyTable entry:" );
|
||||
Console.WriteLine( line );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue