Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryParseInt32()

static bool System.Xml.XmlConverter.TryParseInt32 ( byte[] chars,
int offset,
int count,
out int result )
inlinestaticprivate

Definition at line 569 of file XmlConverter.cs.

570 {
571 result = 0;
572 if (count == 0)
573 {
574 return false;
575 }
576 int num = 0;
577 int num2 = offset + count;
578 if (chars[offset] == 45)
579 {
580 if (count == 1)
581 {
582 return false;
583 }
584 for (int i = offset + 1; i < num2; i++)
585 {
586 int num3 = chars[i] - 48;
587 if ((uint)num3 > 9u)
588 {
589 return false;
590 }
591 if (num < -214748364)
592 {
593 return false;
594 }
595 num *= 10;
596 if (num < int.MinValue + num3)
597 {
598 return false;
599 }
600 num -= num3;
601 }
602 }
603 else
604 {
605 for (int j = offset; j < num2; j++)
606 {
607 int num4 = chars[j] - 48;
608 if ((uint)num4 > 9u)
609 {
610 return false;
611 }
612 if (num > 214748364)
613 {
614 return false;
615 }
616 num *= 10;
617 if (num > int.MaxValue - num4)
618 {
619 return false;
620 }
621 num += num4;
622 }
623 }
624 result = num;
625 return true;
626 }

References System.chars, System.count, System.Xml.Dictionary, and System.offset.

Referenced by System.Xml.XmlConverter.ToInt32(), and System.Xml.XmlConverter.TryParseInt64().