Page 1 of 1

creating the packet( array within an array (nested)

Posted: Thu Jun 15, 2017 4:52 am
by Ememjr
i am trying to add info to the item packet as follows, but unsure how to add info to array within array of course once i figure out proper format to populate i will code it correctly from item information

Code: Select all

packet->setDataByName("footer_set_name", "test footer set name");
packet->setArrayLengthByName("set_bonus_list_count", 1);// list of the bonus items
	packet->setArrayDataByName("footer_set_bonus_items_needed", 1, 0);  //this is nember of items needed for the stat //name,value,array
	packet->setSubArrayLengthByName("set_bonus_stats_count", 1, 0,0);//name,value,array,subarray
		packet->setSubArrayDataByName("set_stat_type", 6, 0,0);
		packet->setSubArrayDataByName("set_stat_subtype", 53, 0, 0);
		packet->setSubArrayDataByName("set_value", 26, 0, 0);
		packet->setSubArrayDataByName("set_stat_name", "", 0, 0);
edit for the new revelations i found

Re: creating the packet( array within an array (nested)

Posted: Thu Jun 15, 2017 6:26 pm
by Jabantiz
I see you edited the post and have the subarray functions so did you figure it out or do you have more questions?

Also note we can only do 2 arrays like this, if you needed a third nested array we don't support that.

Re: creating the packet( array within an array (nested)

Posted: Fri Jun 16, 2017 3:39 am
by Ememjr
yes i edited it but its still not working like i want,
i will snip the result i am getting
i thought i saw a need for an additional sub array but have to find it again, would it be hard to implement anothe subsubarray if we needed it?

Re: creating the packet( array within an array (nested)

Posted: Fri Jun 16, 2017 4:03 am
by Ememjr
test adorn.JPG
heres the code i used, but it only adds the footer set name the the count of items

Code: Select all

packet->setDataByName("item_types",adornment_info->item_types);
				packet->setDataByName("duration", adornment_info->duration); // need to calcualte for remaining duration
				packet->setDataByName("slot_type", adornment_info->slot_type);
				packet->setDataByName("footer_set_name", "test footer set name");
				packet->setArrayLengthByName("footer_set_bonus_list_count", 1);// list of the bonus items
					packet->setArrayDataByName("footer_set_bonus_items_needed", 2, 0);  //this is nember of items needed for granteing that  stat //name,value,array
					packet->setSubArrayLengthByName("footer_set_bonus_stats_count", 2, 0);//name,value,array,subarray
						packet->setSubArrayDataByName("set_stat_type", 5, 0,0);
						packet->setSubArrayDataByName("set_stat_subtype", 1, 0, 0);
						packet->setSubArrayDataByName("set_value", 25000, 0, 0);
as you can see from the packet snip below where i highlighted in red the 01 is getting the foote_set_bouns_list_count but nothing else is in the packet

416: FF FF FF FF FF FF 00 14 - 74 65 73 74 20 66 6F 6F | ........test foo
432: 74 65 72 20 73 65 74 20 - 6E 61 6D 65 01 00 00 00 | ter set name....
448: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 | ................
464: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 | ................
480: 00 00 00 00 00 00 00 00 - 21 46 6C 69 63 6B 65 72 | ........!Flicker
496: 69 6E 67 20 41 72 63 74 - 69 63 20 50 6F 6C 69 73 | ing Arctic Polis
512: 68 69 6E 67 20 53 74 6F - 6E 65 00 00 00 | hing Stone...

Re: creating the packet( array within an array (nested)

Posted: Fri Jun 16, 2017 4:08 am
by Ememjr
here is the portion of the items struct it pertains to

Code: Select all

<Data ElementName="set_name" Type="EQ2_8Bit_String" Size="1" />
<Data ElementName="set_bonus_list_count" Type="int8" IfVariableSet="footer_set_name_0" />
<Data ElementName="set_bonus_list_array" Type="Array" ArraySizeVariable="set_bonus_list_count">
  <Data ElementName="set_bonus_items_needed" Type="int8" Size="1" />
  <Data ElementName="set_bonus_stats_count" Type="int8" />
  <Data ElementName="set_bonus_stats_array" Type="Array" ArraySizeVariable="set_bonus_stats_count" >
    <Data ElementName="set_stat_type" Type="int16" OversizedValue="127" OversizedByte="127" Size="1" />
    <Data ElementName="set_stat_subtype" Type="int16" OversizedValue="127" OversizedByte="127" IfVariableNotEquals="set_stat_type_%i" Size="1" />
    <Data ElementName="set_value" Type="float" Type2="sint32" Type2Criteria="set_stat_type!=6"  />
    <Data ElementName="set_stat_name" Type="EQ2_8Bit_String" Size="1" />
	<Data ElementName="set_stat_unknown" Type="int32" Size="1" />
	<Data ElementName="set_stat_unknownmj2" Type="int16" Size="1" />
  </Data>
  <Data ElementName="set_bonus_effects_count" Type="int8" />
  <Data ElementName="set_bonus_effects_array" Type="Array" ArraySizeVariable="set_bonus_effects_count">
    <Data ElementName="set_bonus_effect_subbulletflag" Type="int8" Size = "1" />
    <Data ElementName="set_bonus_effect_text" Type="EQ2_16Bit_String" Size="1" />
    <Data ElementName="set_bonus_effect_percentage" Type="int8" Size = "1" />
  </Data>
</Data>

Re: creating the packet( array within an array (nested)

Posted: Fri Jun 16, 2017 6:59 pm
by Jabantiz
I don't really work with this code so I honestly have no clue how hard it would be to add a 3rd nested array. It really needs a subarray on a substruct though.

try changing "footer_set_bonus_items_needed" to "footer_set_bonus_items_needed_0" and see if it gets included into the packet.

Re: creating the packet( array within an array (nested)

Posted: Tue Jul 18, 2017 5:14 pm
by Ememjr
so i am trying to make this 3rd array into a substruct and not sure if this is the proper way
her is the orginal struct, as you will sill there are 3 nested arrays in the template

Code: Select all

<Data ElementName="num_templates_array" Type="Array" ArraySizeVariable="num_templates" >
  <Data ElementName="template_unknown1" Type="int8" Size="1" />
  <Data ElementName="template_name" Type="EQ2_16Bit_String" />
  <Data ElementName="template_unknown2" Type="int8" Size="1" />
  <Data ElementName="num_tabs" Type="int16" Size="1" />
  <Data ElementName="tab_template_array" Type="Array" ArraySizeVariable="num_tabs" >
    <Data ElementName="tab_number" Type="int16" Size="1" />
    <Data ElementName="tab_unknown1" Type="int32" Size="1" />
    <Data ElementName="template_size" Type="int16" Size="1" />
    <Data ElementName="template_array" Type="Array" ArraySizeVariable="template_size" >
      <Data ElementName="template_pos" Type="int16" Size="1" />
      <Data ElementName="template_unknown3" Type="int16" Size="1" />
      <Data ElementName="template_id" Type="int32" Size="1" />
    </Data>
  </Data>
</Data>
here is my attempt to make the 3rd array (template_array) into a separate struct since we dont have have to populate an array 3 level nested

Code: Select all

<Data ElementName="num_templates_array" Type="Array" ArraySizeVariable="num_templates" >
  <Data ElementName="template_unknown1" Type="int8" Size="1" />
  <Data ElementName="template_name" Type="EQ2_16Bit_String" />
  <Data ElementName="template_active" Type="int8" Size="1" />
  <Data ElementName="num_tabs" Type="int16" Size="1" />
  <Data ElementName="tab_template_array" Type="Array" ArraySizeVariable="num_tabs" >
    <Data ElementName="tab_number" Type="int16" Size="1" />
    <Data ElementName="tab_unknown1" Type="int32" Size="1" />
    <Data ElementName="info_template" Substruct="WS_info_template" Size="1" />
   </Data>
</Data>
</Struct>
<Struct Name="WS_info_template" ClientVersion="63119">
<Data ElementName="template_size" Type="int16" Size="1" />
    <Data ElementName="template_array" Type="Array" ArraySizeVariable="template_size" >
      <Data ElementName="template_pos" Type="int16" Size="1" />
      <Data ElementName="template_unknown3" Type="int16" Size="1" />
      <Data ElementName="template_id" Type="int32" Size="1" />
    </Data>
</Struct>

Re: creating the packet( array within an array (nested)

Posted: Wed Jul 19, 2017 3:03 am
by Ememjr
I figured out what i was doing wrong, (the substruct was not showing up in the ANAL, i had to move the substruct above the main structure in the worldstructs.xml and now its being seen