• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Can we have members of structs inside the same struct?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

If we have some struct myStruct and I give it an array of myStruct as a field, will this be ok behavior wise, or will there be any funny issues arising?

JASS:
struct myStruct
  myStruct array[5]
  static method create takes nothing returns nothing
  ...
  endmethod
  ...
endstruct

I know it compiles and everything. But I've made a struct just like this and it's behavior starts to get "unpredictable" once I use it more than once, and I am not even exceeding 8192 instances (or 8192 / highest array size).
 
myStruct translates into integer array[5], which translations into an array that uses multiplication to access 2nd dimension elements.

There would be no issues. Keep in mind that your array would not be initialized, meaning that everything would be 0. You would have to create the things yourself.

You can also type an a to produce a syntax error and look at the generated code to see what would happen for yourself. There is no need to ask ;).
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
I've been doing a lot of sanity checks Nestharus and unfortunately they keep failing. Testing various things and using debug messages, etc. So since I have been testing out and checking things myself, but my issues remain unsolved, I'm either lacking information or my logic is off in some subtle way. In either case it helps to bring in someone else as an additional sanity check.

Problem is there's no set of traces to look at for my function calls. If I had that entire set of traces, then I could pretty quickly know what's the issue. I'm talking about traces for the high level function calls, e.g. "called myStruct.create(...)" and not low-level stuff.
 
Status
Not open for further replies.
Top