wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Warcraft Editing Tools
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 07-27-2009, 12:56 PM   #2161
Dark_Dragon
User
 
Dark_Dragon's Avatar
 
Join Date: Apr 2008
Posts: 189

Dark_Dragon has little to show at this moment (9)

Default

Quote:
Originally Posted by daPanda
I have a few questions about allocation if someone could clarify plz.


on another forum I was reading a post about global structure allocation. someone had posted the following:

Collapse JASS:
struct Branch   
//data
endstruct

globals   
Branch array STBRANCH[500]
endglobals

function test takes nothing returns nothing
   set STBRANCH[1] = Branch.create()   
   set STBRANCH[2] = Branch.create()
endfunction

someone replied that the calls in the function to create each array element wasn't necessary because global array elements don't need to be created or destroyed.

another person in the same thread also said that the following is also legit without allocating it each array element:

Collapse JASS:
struct name extends array
     real x
     real y
endstruct

function bla takes nothing returns nothing
     set name[1].x = 5.
     set name[2].y = 6.
endfunction

without even having to declare a global var or allocate each element.

but, when I try to do this, the data I store is unstable. I can't see anywhere in the output code where name[1] or name[2] is assigned a pointer (allocated) with the above code "as is".

In my mind, it seems necessary to do the following first before using the above:
set name[1] = name.create()
set name[2] = name.create()

I've always done it this way (allocating each array element). When I tested the above by removing the .create() from my global struct array elements, the data is unreliable.

are they correct in saying that the array elements don't have to be allocated manually if they are global struct arrays? I mean, I know they array itself is allocated (obviously) but each element is allocated as well?

their statements have me confused.

thanks for your input

the first part when someone said that array globals do not need to be allocated was wrong! why? coz that struct does not extend array... second example was correct and you dont need to allocate them since they extend array... which means there is no .create or .destroy methodes... thats coz array structs are usefull when it comes for player id works or simply if you need your own indexing system implemented.

and so its true that in array structs like u said! each element is allocated by you when you use it! no need for .create or anything like that since extending array means that it is automatically allocated when you insert specific index...

Quote:
Line 62438: memory exhausted.
wtf?!

would u mind sending that line here?
__________________
Undefined shadow...

Last edited by Dark_Dragon : 07-27-2009 at 12:58 PM.
Dark_Dragon is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 07-27-2009, 01:42 PM   #2162
Eleandor
User
 
Join Date: Jan 2006
Posts: 118

Eleandor is on a distinguished road (12)

Default

Quote:
Originally Posted by Litany
Your grasp of predication and inherence is not so good.

Will anyone ever create a shape? No. They'll create circles or squares, but never ever shapes. Therefor, shapes should not be structs. It's as simple as that.
Eleandor is offline   Reply With Quote
Old 07-27-2009, 02:23 PM   #2163
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
Will anyone ever create a shape? No. They'll create circles or squares, but never ever shapes. Therefor, shapes should not be structs. It's as simple as that.
As I said before, it depends on your implementation. You are not aware of the system, therefore you do not have as much authority as Litany has to discuss it.

Please stop this arguments, we are here to talk about vJass, not about a Shape system.

And thx to dragoon for showing me delegate =D
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 07-27-2009 at 02:24 PM.
Flame_Phoenix is offline   Reply With Quote
Old 07-27-2009, 04:45 PM   #2164
Dark_Dragon
User
 
Dark_Dragon's Avatar
 
Join Date: Apr 2008
Posts: 189

Dark_Dragon has little to show at this moment (9)

Default

Quote:
Originally Posted by Flame_Phoenix
As I said before, it depends on your implementation. You are not aware of the system, therefore you do not have as much authority as Litany has to discuss it.

Please stop this arguments, we are here to talk about vJass, not about a Shape system.

And thx to dragoon for showing me delegate =D

you are welcome ;)
__________________
Undefined shadow...
Dark_Dragon is offline   Reply With Quote
Old 07-27-2009, 07:04 PM   #2165
daPanda
User
 
Join Date: Jan 2009
Posts: 28

daPanda has little to show at this moment (0)

Default

Thanks Dragon.
daPanda is offline   Reply With Quote
Old 07-27-2009, 07:17 PM
Litany
This message has been deleted by Litany.
Old 07-27-2009, 07:21 PM   #2166
Dark_Dragon
User
 
Dark_Dragon's Avatar
 
Join Date: Apr 2008
Posts: 189

Dark_Dragon has little to show at this moment (9)

Default

Quote:
Originally Posted by daPanda
Thanks Dragon.

np and btw just one thing i forgot!

Collapse JASS:
struct test extends array
   real x
   real y
   real z
endstruct

function testfunc takes nothing returns nothing
    local test t


    set test[1].x = 3.
    set test[1].y = 4.
    set test[1].z = 5.
    set test[2].x = 6.
    set test[2].y = 7.
    set test[2].z = 8

     // insted of that long stuff u can do this:
     set t = test(1)
     set t.x = 3.
     set t.y = 4.
     set t.z = 5.
     set t = test(integer(t) + 1)
     set t.x = 6.
     set t.y = 7.
     set t.z = 8.

     // will do same as array accessing! but its lesser to write :D
     // so pick one u like more
endfunction

Greets!
~DD

EDIT:
Quote:
He said "A "shape" is not *real*." This is wrong.

hmm well to say the truth! both of you are correct! shape is real and is not... ofc it can be only one of this but from point of you two guys are looking... the result is that both of u are correct.

you are looking at shape as an "in programming" object which can be line, circle... which would be "real" coz we know what line or circle is and therefore we can know what shape would be... any of this ofc! since you look at it that way it would be real.

from point Eleandor is looking is well! shape is not known what it is at beginning... line, circle... so he is looking at them as we look at re+im or (x+yi)! well x would be real like line or circle and yi would be shape... well we can write yi! or y*sqrt(-1) but we cant immagine what it is other then that its on second dimension... so we can say that for shape we know it but we dont!

i cant explain this to good but i understand what both of ur are talking about... so yeah from my point of view both of u are correct since every one of u sees it different!
__________________
Undefined shadow...

Last edited by Dark_Dragon : 07-27-2009 at 07:33 PM.
Dark_Dragon is offline   Reply With Quote
Old 07-27-2009, 08:05 PM
Litany
This message has been deleted by Litany.
Old 07-28-2009, 04:25 AM   #2167
Alevice
It feels good
 
Alevice's Avatar
 
Join Date: Mar 2006
Posts: 1,305

Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)

Default

Quote:
Originally Posted by Alevice
I was thinking about that later on. I personally don't like the underscore notation for scoping and such, but it surely is a wrokaround. Pluse you don't have something like "using scope MyScope" and go the short way when you know your name might not collide somewhere else (not that it matters much).

Thanks for the input.


Alright, for the record, scopes and libraries can't be nested, so ditch that.

Also, I don't know if this is a bug or a deliberate design behaviour but I find it odd: it seems structs within libraries get their static members declared after global variables in goddamned scopes. COme the fuck on. Case in point

Collapse JASS:
library UnitIds
    private keyword KR_Units
    struct KalimdorRaiders
        static KR_Units Units
    endstruct
    
    private struct KR_Units
        static constant integer KOBOLD_MINER = 'kru0'
        static constant integer KODO_WAGON = 'kru1'
        static constant integer KODO_OFFSPRING = 'kru2'
        static constant integer KODO_OFFSPRING2 = 'krm2'
        static constant integer CENTAUR_DRUDGE = 'kru3'
        static constant integer CENTAUR_ARCHER = 'kru4'
        static constant integer OGRE_CRUSHER = 'kru5'
        static constant integer OGRE_CRUSHER2 = 'krm5'
        static constant integer HARPY_SCOUT = 'kru6'
        static constant integer HARPY_WITCH = 'kru7'
        
        static constant integer OGRE_CRUSHER_SIEGE = 'kru8'
        static constant integer OGRE_CRUSHER_SIEGE2 = 'krm8'
    
    endstruct
endlibrary

scope Marionette initializer Init

    globals
        private constant integer CASTER_ID = KalimdorRaiders.Units.HARPY_WITCH
    endglobals
    
endscope

It tells me KalimdorRaiders is an undeclared variable.
__________________
_-|-_

Alevice.jones is SC2 Beta, losers.

Check out my never updated deviantart gallery!!

Kalimdor Raiders (Race Contest #1) Pastebin Page
Cavern Crawlers (Race Contest #2) Pastebin Page
Airship Race Motherfuckers!
Quote:
Originally Posted by http://ajaxian.com/archives/would-you-like-a-_-with-that-new-library-gives-js-what-it-should-have#comment-276203
- Dont solve problems that dont exist.
- Improve the wheel, dont reinvent it.
- Port the wheel if it doesnt exist in your environment.
- Integrate the wheel into your project.
- Make sure you can replace your wooden wheel for a rubber one if someone else invents it.
Alevice is offline   Reply With Quote
Old 07-28-2009, 04:37 AM   #2168
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

variables from structs are added after other global variables. No matter if it is a library or a scope or whatever. My solution? Assign the global post- globals init ...

I don't think there is a way to change this rule any time soon, as long as structs are compiled in a separate phase, it won't.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 07-28-2009, 04:43 AM   #2169
daPanda
User
 
Join Date: Jan 2009
Posts: 28

daPanda has little to show at this moment (0)

Default

thanks again dragon. one more question about that if you don't mine.

What if the extended struct contains another struct? is it also allocated?

Collapse JASS:
struct name1 extends array
   integer a
   integer b
endstruct

struct name2 extends array
     name1
     real x
     real y
endstruct

function bla takes nothing returns nothing
     set name2[1].x = 5.
     set name2[2].y = 6.

    set name2[1].name1[1].a = 5
    etc...
endfunction
is that legit?
daPanda is offline   Reply With Quote
Old 07-28-2009, 05:05 PM   #2170
Dark_Dragon
User
 
Dark_Dragon's Avatar
 
Join Date: Apr 2008
Posts: 189

Dark_Dragon has little to show at this moment (9)

Default

Quote:
Originally Posted by daPanda
thanks again dragon. one more question about that if you don't mine.

What if the extended struct contains another struct? is it also allocated?

Collapse JASS:
struct name1 extends array
   integer a
   integer b
endstruct

struct name2 extends array
     name1
     real x
     real y
endstruct

function bla takes nothing returns nothing
     set name2[1].x = 5.
     set name2[2].y = 6.

    set name2[1].name1[1].a = 5
    etc...
endfunction
is that legit?

yes you can have struct inside the struct but this:
Collapse JASS:
struct name2 extends array
     name1
     real x
     real y
endstruct

function bla takes nothing returns nothing
     set name2[1].x = 5.
     set name2[2].y = 6.

    set name2[1].name1[1].a = 5
    etc...
endfunction

should be:

Collapse JASS:
struct name2 extends array
     name1 n1
     real x
     real y
endstruct

function bla takes nothing returns nothing
     set name2[1].x = 5.
     set name2[2].y = 6.

     set name2[1].n1 = name1(1)
    set name2[1].n1.a = 5
    etc...
endfunction
__________________
Undefined shadow...

Last edited by Dark_Dragon : 07-28-2009 at 05:06 PM.
Dark_Dragon is offline   Reply With Quote
Old 07-29-2009, 10:10 AM   #2171
Dark_Dragon
User
 
Dark_Dragon's Avatar
 
Join Date: Apr 2008
Posts: 189

Dark_Dragon has little to show at this moment (9)

Default

Quote:
Originally Posted by Vexorian
variables from structs are added after other global variables. No matter if it is a library or a scope or whatever. My solution? Assign the global post- globals init ...

I don't think there is a way to change this rule any time soon, as long as structs are compiled in a separate phase, it won't.

then how are static variables sorted? if i wrote one in library and one in scope will that one in library be declared before that one in scope? or are they randomly added after globals?

btw static variables should be really like they are now coz if they get messed with globals many of constants might not be accessable... and from view we are looking at structs in c++ or some other OOP language constant static variables should be allowed to always be assigned with other global constants...

btw structs here are more like classes in c++! so when i am saying structs i mean classes in c++...
__________________
Undefined shadow...

Last edited by Dark_Dragon : 07-29-2009 at 10:12 AM.
Dark_Dragon is offline   Reply With Quote
Old 07-29-2009, 04:04 PM   #2172
Element of Water
User
 
Element of Water's Avatar
 
Join Date: Mar 2009
Posts: 147

Submissions (2)

Element of Water is on a distinguished road (18)

BUG BUG

Just a little problem with the syntax checker. If you do something like this:

Collapse JASS:
struct MyStruct
    local integer i = //syntax error
endstruct

JassHelper doesn't notice this; it throws up a syntax error in the generated allocator function, rather than saying there's an error in the struct. When this happened to me it took me about 10 minutes to work out what I did wrong. Please fix it.

EDIT: I have a request - please make the newline character ("\n") be considered in textmacros, so for example, I could do something like this:

Collapse JASS:
//! textmacro MyTextmacro takes NAME, VARS
struct $NAME$
    $VARS$
endstruct
//! endtextmacro

//! runtextmacro MyTextmacro ("Data", "real x\nreal y\nunit u")
which compiles to this:
Collapse JASS:
struct Data
    real x
    real y
    unit u
endstruct

Last edited by Element of Water : 07-29-2009 at 06:18 PM.
Element of Water is offline   Reply With Quote
Old 07-30-2009, 02:44 PM   #2173
Barade
User
 
Barade's Avatar
 
Join Date: May 2006
Posts: 161

Barade is on a distinguished road (14)

Default

Quote:
Originally Posted by Dark_Dragon
then how are static variables sorted? if i wrote one in library and one in scope will that one in library be declared before that one in scope? or are they randomly added after globals?

btw static variables should be really like they are now coz if they get messed with globals many of constants might not be accessable... and from view we are looking at structs in c++ or some other OOP language constant static variables should be allowed to always be assigned with other global constants...

btw structs here are more like classes in c++! so when i am saying structs i mean classes in c++...
The only difference between structs and classes in C++ is that struct members are public by default. So structs in vJass are like structs in C++.
Btw. I can not assign some constant variables as array member size like bj_MAX_PLAYERS. A better global variable treatment would be useful.
__________________
Barade is offline   Reply With Quote
Old 07-30-2009, 02:49 PM   #2174
Dark_Dragon
User
 
Dark_Dragon's Avatar
 
Join Date: Apr 2008
Posts: 189

Dark_Dragon has little to show at this moment (9)

Default

Quote:
Originally Posted by Barade
The only difference between structs and classes in C++ is that struct members are public by default. So structs in vJass are like structs in C++.

i see... well i knew that classes are private (by default) and structs not! however can structs have methodes? in school we used structs only for group of variables. no methodes. anyway ty.

Quote:
Btw. I can not assign some constant variables as array member size like bj_MAX_PLAYERS. A better global variable treatment would be useful.

well that might be true, well its just since i never needed it so i did not think to much about it. however for some people yeah could need some more work :P
__________________
Undefined shadow...
Dark_Dragon is offline   Reply With Quote
Old 07-30-2009, 03:53 PM   #2175
Alevice
It feels good
 
Alevice's Avatar
 
Join Date: Mar 2006
Posts: 1,305

Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)

Default

STructs in c++ can have methods.

Anyway, sucks to hear that Vex :( Oh well, time to redesign then :/
__________________
_-|-_

Alevice.jones is SC2 Beta, losers.

Check out my never updated deviantart gallery!!

Kalimdor Raiders (Race Contest #1) Pastebin Page
Cavern Crawlers (Race Contest #2) Pastebin Page
Airship Race Motherfuckers!
Quote:
Originally Posted by http://ajaxian.com/archives/would-you-like-a-_-with-that-new-library-gives-js-what-it-should-have#comment-276203
- Dont solve problems that dont exist.
- Improve the wheel, dont reinvent it.
- Port the wheel if it doesnt exist in your environment.
- Integrate the wheel into your project.
- Make sure you can replace your wooden wheel for a rubber one if someone else invents it.
Alevice is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 02:09 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services