Struct arrays

EQ2Emulator Development forum.

Moderator: Team Members

Post Reply
User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Struct arrays

Post by Ememjr » Thu Jun 29, 2017 7:22 am

what are the consequences if i set the array length to lets say 5

Code: Select all

packet->setSubstructArrayLengthByName("header_info", "stat_count", 5);
and then set the array data as seen below for

Code: Select all

packet->setArrayDataByName("stat_type", stat->stat_type, 0);
packet->setArrayDataByName("stat_subtype", tmp_subtype, 0);
packet->setArrayDataByName("stat_type", stat->stat_type, 1);
packet->setArrayDataByName("stat_subtype", tmp_subtype, 1);
packet->setArrayDataByName("stat_type", stat->stat_type, 2);
packet->setArrayDataByName("stat_subtype", tmp_subtype, 2);
packet->setArrayDataByName("stat_type", stat->stat_type, 3);
packet->setArrayDataByName("stat_subtype", tmp_subtype, 3);
and then go back and change the array length back to 4

Code: Select all

packet->setSubstructArrayLengthByName("header_info", "stat_count", 4);
does it wipe the 0 to 3 data i already put in or does it just change the array count
I would only be making the array smaller not larger if this is possible

the reasoning behind this is if you have an item with potency on it in the stat list and there are 5 stats, the 5 is the array size
but if you are using DOV client or another client that the stat is not in, i dont want that stat in the array and would skip adding it to the packet, but then would need to change the array size

i could work around this by reading all the stats for that item and placing them in a temp array, then reading that temp array to determine what stat number to send to the client based on the client version but that seems like double work

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Struct arrays

Post by John Adams » Thu Jun 29, 2017 9:17 am

If it were me, I'd probably just write code that checks for minimum client version, and branch to do it 2 different ways.

Code: Select all

if (version = DOV) { // do 4 elements } else { // do 5 elements }
but then, this is why I am a DB guy, not a C++ guy :)

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Struct arrays

Post by Ememjr » Thu Jun 29, 2017 10:00 am

doubt that would work beacuse there could be more than one element that doesnt apply, since dbg seems to change stats alot

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Struct arrays

Post by Zcoretri » Thu Jun 29, 2017 12:36 pm

I would think the only thing that would happen is when your array size is at 5, that 5th elements data will be sent to the client with value 0.
Hopefully Jabantiz can explain it better.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests