Author Topic: DataNode Error  (Read 1875 times)

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
DataNode Error
« on: August 16, 2016, 08:57:32 PM »
In the following DataNode:
(I can use bytes in this case, but this error needs attention)

Resolves fine:
  1. int phpbb_id = info.data.GetChild("phpbb_id", 0);

Causes an error:
  1. int min_level = info.data.GetChild("min_level", 0);
  2. int max_level = info.data.GetChild("max_level", 0);
  3.  
  4. //Unable to convert System.Byte (1) to System.Int32

  1. Version = 20160207
  2.         type = "Match"
  3.         phpbb_id = 2
  4.         isPrivate = false
  5.         match_type = "Conquest"
  6.         arena_index = 10
  7.         arenaname = "Dev Map"
  8.         min_level = 1
  9.         max_level = 2
  10.         founder = "Pitch Black"
  11.         duration = 15
  12.         start = 636069937084710000
  13.         rules = "1,2"
  14.         teams = "Order,Yellow"
  15.         invited = ""
  16.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: DataNode Error
« Reply #1 on: August 17, 2016, 06:53:39 AM »
Seems to work fine here. Byte can be cast to an int, it's done on line 377 of TNSerializer.cs, in the CastValue function.

Also, why is it a byte anyway? Every number is read as an integer when you parse a text data file.

Lastly, I'd do it like this: int max_level = info.data.GetChild<int>("max_level");