• 🏆 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!

Struct saving in gamecache?

Status
Not open for further replies.
Level 12
Joined
May 21, 2009
Messages
994
So I'm creating a single player campaign which consist of 5 maps (Diablo II Recreation) the thing is, I'm wondering if you:

JASS:
struct mystruct
real r
static method create takes real r returns mystruct
local mystruct = mystruct.allocate()
set .r = r
endmethod
endstruct
then if I call:
JASS:
local mystruct m = mystruct.create(3.)
call StoreInteger(gamecache, "1", "2", Struct)
will it then transfer the real (3.) to the map that I'm loading the gamecache in? so I can get the struct via
JASS:
GetStoredInteger(gamecache, "1", "2", m)
?
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
Logically no, you do not understand how structs work.

Structs are nothing more than a parallel arrays. The struct reference is an integer to the array index. Thus storing the index will not store the data at that index in the array. Furthermore, structs need not be regenerated at the same index. Thus storing the index is pointless.
 
Level 12
Joined
May 21, 2009
Messages
994
Logically no, you do not understand how structs work.

Structs are nothing more than a parallel arrays. The struct reference is an integer to the array index. Thus storing the index will not store the data at that index in the array. Furthermore, structs need not be regenerated at the same index. Thus storing the index is pointless.

I was kinda sure it couldn't, just wanted to be sure. Thanks.
 
Status
Not open for further replies.
Top