• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Can we have members of structs inside the same struct?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
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).
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
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,337
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