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.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      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