Moar questions about 'this'

SineCosine

I'm still looking for my Tangent
Reaction score
77
Since 'this' refers to the instance of the struct..
If I use something like:
JASS:

call BJDebugMsg(I2S(this))


Will I get a number from 0 to 8190 ? :D
 

Crazy_Dead

New Member
Reaction score
24
Please, spell things right. Seriously ,this is annoying me like shit. :p

Noothing constructive from me. Sorry. :(
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
What am I spelling wrong?
What part of my post annoyed you like "shit"?

Please, enlighten me, fellow brother.
 

Crazy_Dead

New Member
Reaction score
24
Moar. I thought you did know that. Moar = More. Simple English, brother.

Also, its 8191 not 8190. :D
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
One mere word and you're about to flip?

Wan miier werd an euu'rr erbaut tu fleep?

1 mr wrd n ur abt 2 flp?

1mrwdnurb2flp?
/Off topic

I'll keep that 8191 in mind.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
No, it's actually 0 - 8190, but there's 8191 instances :p

And yes, the structs should show you an integer like it ;)
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Sweet..
I have another question!

Do linked lists work by using that (this, this - 1, this + 1, or something like that, lol)?
Because I'm having trouble understanding the applications for linked lists and how to use them =x

[EDIT]
I just tried it..
Why did it start from 1 and not 0?
[lJASS]call BJDebugMsg(I2S(this))[/lJASS] returned '1' instead of '0' the first time I ran it ._.
 
Reaction score
91
You can always try that (your first question) but I'm wondering whether or not it should be typecasted to integer. Something like:
[ljass]call BJDebugMsg(I2S(integer(this)))[/ljass]
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
What's typecasting? =x

[EDIT]
I tried both [lJASS]call BJDebugMsg(I2S(this))[/lJASS] and [lJASS]call BJDebugMsg(I2S(integer(this)))[/lJASS],
They both give me '1' and not '0' when I first run it ._.
 

Crazy_Dead

New Member
Reaction score
24
One mere word and you're about to flip?

Wan miier werd an euu'rr erbaut tu fleep?

1 mr wrd n ur abt 2 flp?

1mrwdnurb2flp?
/Off topic

I'll keep that 8191 in mind.

OMG! Stop it. Please. Cause
Take all the time you need to write your posts, forums are not the same as chat - for example instead of writing "gratz" or "ne1" you should use "congratulations" and "anyone" so that everybody can understand you easily. Also try to put periods and capital letters where they're supposed to be, this greatly increases readability. Acronyms are OK, but try to avoid leetspeak.

This doesnt work, cause it starting to get annoying.

@Koma

Sorry, yes you are right 8190 but 8191 instances. Sorry. :p
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Say, what?
That one word, "Moar", will make my query hard to understand?
I am so very sorry that you feel this way.

I already know that I may not be answered immediately and that I have to be patient and neat in my presentation.

But, please answer me, how was I being impatient and messy in the presentation of my curiosity?

[EDIT]
Yea, flip me the bird while you're at it, why don't you?
You just edited your post with a new quote.

Allow me to reply to that with as little leetspeak as possible.
I am not saving time by typing the word "moar", the words "more" and "moar" have the same number of characters, see?
The point of the message in that quote is that posts are supposed to be readable.

Is the point of this post/thread any less understandable because I used the word "moar" instead or "more"?
Why, I believe the answer is 'no'.

Thanks for trying to make me a better person.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Just ignore him, it's just that you have written 'Moar' instead of 'More' in every post you've made... Just try to think about that ;)

And also, for the "returns 1 instead of 0" thing, I believe that structs actually only range from 1 - 8190, as 0 is always 0, as in nothing XD
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Struct Allocation:



JASS:
struct A
endstruct



==>


JASS:

globals


//JASSHelper struct globals:
constant integer si__A=1
integer si__A_F=0
integer si__A_I=0
integer array si__A_V

endglobals


//Generated allocator of A
function s__A__allocate takes nothing returns integer
 local integer this=si__A_F
    if (this!=0) then
        set si__A_F=si__A_V[this]
    else
        set si__A_I=si__A_I+1
        set this=si__A_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__A_V[this]=-1
 return this
endfunction

//Generated destructor of A
function s__A_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__A_V[this]!=-1) then
        return
    endif
    set si__A_V[this]=si__A_F
    set si__A_F=this
endfunction



As you can see, "if this > 8190 then return 0".

Struct indices range from 1 to 8190, for a total maximum 8190 instances. The 8191 spot in the array is not used because historically use of that spot in arrays causes saved game issues (If I recall correctly. In any case, people usually avoid using it.). The 0 spot is returned when the indexes have run out, but is not used normally, because it's the traditional "null" index for structs.




Anyway, if you ever wonder how something in vJass functions, just compile it and look at the j file. The mechanics of these things should not be a debate.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Thanks =)
But all that machine letter made it hard to understand ._.

JASS:
globals
//JASSHelper struct globals:
constant integer struct_A=1
integer struct_A_F=0
integer struct_A_I=0
integer array struct_A_V

endglobals


//Generated allocator of A
function s__A__allocate takes nothing returns integer
 local integer this=struct_A_F
    if (this!=0) then
        set struct_A_F=struct_A_V[this]
    else
        set struct_A_I=struct_A_I+1
        set this=struct_A_I
    endif
    if (this>8190) then
        return 0
    endif

    set struct_A_V[this]=-1
 return this
endfunction

//Generated destructor of A
function s__A_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (struct_A_V[this]!=-1) then
        return
    endif
    set struct_A_V[this]=struct_A_F
    set struct_A_F=this
endfunction


*Reads*
So..
The reason why I'm getting '1' and not '0' is because of this:
JASS:
    else
        set struct_A_I=struct_A_I+1
        set this=struct_A_I


Where struct_A_I is originally '0' and becomes '1'.
Then, when there are 2 of the instances..

I duno.
Because it checks for the value of struct_A_F and not struct_A_I ._.

What does this mean?
[lJASS]set si__A_V[this]=-1[/lJASS]

[EDIT]
Wait--
So, [lJASS]si__A_I[/lJASS] is the number of instances of a struct that's running?
si__A_F would be the lowest number of a free struct, one that isn't running?

[EDIT=2]
Okay..
So..
01) 1st instance of struct is run..
02) si__A_I turns from '0' to '1'
03) this becomes si__A_I, which is '1'
04) si__A_V[1] becomes '-1'

05) 2nd instance of struct is run..
06) si__A_I turns from '1' to '2'
07) this becomes si__A_I, which is '2'
08) si__A_V[2] becomes '-1'

09) I want to deallocate the 1st instance of the struct..
10) this is not null and it is -1, so it passes the check..
11) si__A_V[1] becomes si__A_F, which is '0', because the value of si__A_F has not changed yet.
12) si__A_F becomes '1'

13) 3rd instance of struct is run.. (Well, 2nd, but we'll call it 3rd for my sanity's sake, hard to understand this >.>)
14) this becomes si__A_F, which is '1'
15) si__A_F becomes si__A_V[1], which is '0'
16) si__A_V[1] becomes '-1'

17) 4th instance of struct is run.. (Again, for my sanity's sake..)
18) this becomes si__A_F, which is '0'
19) si__A_I becomes '3'
20) this becomes si__A_I, which is '3'
21) si__A_V[3] becomes '-1'..

22) I want to deallocate the 2nd struct instance..
23) this is not null and si__A_V[2] is '-1', so it passes the check..
24) si__A_V[2] becomes si__A_F, which is '0'
25) si__A_F becomes this, which is '2'..


HOLY FU----
OMG!
I AM ENLIGHTENED!
IT WORKS!!


I apologize for the capitalized letters, but I think I finally understand part of it ._.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
*Reads*
So..
The reason why I'm getting '1' and not '0' is because of this:
JASS:

    else
        set struct_A_I=struct_A_I+1
        set this=struct_A_I


Where struct_A_I is originally '0' and becomes '1'.
Then, when there are 2 of the instances..

I duno.
Because it checks for the value of struct_A_F and not struct_A_I ._.

From JassHelper Manual:

JassHelper is just a preprocessor not a hack so whatever adition to Jass we add is still limited by Jass' own limitations, in this case, structs use arrays which have a 8191 values limit, and we cannot use index 0 which is null for structs, so there is an 8190 instances limit. This limit is for instances of each type, so you may have 8190 objects of a pair struct type and still are able to have many other instances of other types.

It means that if you keep creating many structs of a type without destroying them you would eventually reach the limit. So keep in mind this: IN the case the instances limit of a type is reached structtype.create() WILL RETURN 0.

In other words, 0 is reserved for a null struct (since there is no 'null' integer), and struct.create() will return a value between 1 and 8191.
 

Bribe

vJass errors are legion
Reaction score
67
struct_A_F value of -1 is to declare it as an active struct, in the event you pass an invalid integer to the "Destroy method", to prevent errors.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Omg, look back one page xD
I think I finally got part of how it works!!

I feel enlightened, somehow!

So..
Structs are basically..
integers? o.0

Ehh..
si__A_F <-- Lowest index (correct name?) in the array of the struct that is free
si__A_I <-- Number of struct instances running
si__A_V <-- The actual array? -1 means 'in use', anything else means inactive.
si__A <--- What's that? o.0

But from what I see..
You'll never know in which order the structs were run.. right?
Hence... The need for linked lists?
 

Bribe

vJass errors are legion
Reaction score
67
Sorry, meant to say struct_A_V, it's hard to read Vexorian's scripts :p

Also, that constant integer is the struct's static id. Using .typeid will reference that constant integer, and .getType() will return the constant integer of an interface.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Yes, structs are integers. Internally the [normal] members are arrays in which the index is the struct integer.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top