[JASS] I was gonna ask something but I forgot

Status
Not open for further replies.
Level 19
Joined
Aug 24, 2007
Messages
2,888
... wait I'll think until I remember...
ah okay lets begin.

1- Is there any difference about leak ?

JASS:
call BJDebugMsg("Spartans")
//
loop
exitwhen i == 100
call BJDebugMsg("Spartans")
set i = i+1
endloop
//
static string sparta = "Spartans"
loop
exitwhen i == 100
call BJDebugMsg(sparta)
set i = i+1
endloop
//
constant string sparta = "Spartans"
loop
exitwhen i == 100
call BJDebugMsg(sparta)
set i = i+1
endloop
//
local string sparta = "Spartans"
call BJDebugMsg(sparta) // Say I run this for 100 times

2- What is the difference between static and constant

(Off-Section)3- About slk files say I have a Abilityblabla.slk file (same with in mpq) imported in my map
What does it do ?
a) Ignores all abilities in map and uses what is inside it
b) Adds the abilities in it to map and repleaces the ones with same rawcode in it with what it has
c) Ignores the standart abilities and uses what is inside it. Leaves the custom ones
d) Custom Answer

I wonder why I didnt use ubercool text colors
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
1) ?
2) Just a guess, but I think this is the difference:
After compilation, every "constant" identifier found in the code is actually replaced with the corresponding value. For instance: if you use
constant real pi = 3,141592...
then, upon saving the map, everytime you encounter "pi" in your code, it's techincally replaced by the direct value 3,141592.
I think statics are set on run-time, so not during the compilation...
3) Again, not sure about this one, but I think option 2.
 
Level 11
Joined
Feb 18, 2004
Messages
394
2) constant denotes a variable whos value can not be changed. They are NOT inlined at compile time. However, vex's map optimizer will inline constant globals. Note that when declaring a constant, you may be able to declare it without an initial value. However, why would you?

static has to do with structs. Namely, if a member variable or a method is static, it does NOT correspond to a specific instance of a struct. Static members exist not once per instance of a struct (an instance being that which .create() returns) but once, within the struct itself. .create() is an example of a static method: you call it off the struct name as opposed to off a variable holding an instance.

Static methods do NOT have access to the "this" variable, as this reffers to a specific instance of the struct. Static methods do not corrospond to an instance and thus do not have a "this". (that means static methods can only read the static variables of a struct.)

constant when applied to a function has to do with the fact that it can not call any other non-constant functions. Its rather useless, however, vex's map optimizer can again inline constant functions as well as constant variable.


3) a SLK file imported in to a map will overwrite the default SLK files in the MPQ. The game will not toutch the SLK files in war3.mpq (or x or patch) if one is present in the map. (Some exceptions to that) Note that the world editor stores object data (units, items, destructables, ext) in a format that only stores the changes from the SLK files the editor is currently using. Thus why the Widgitizer (which converts that data + the origional SLKs in to SLKs which contain the change data) speeds up loading times. Its faster for the game to just read a SLK file then it is for the game to read a SLK file and then read a bunch of changes and build a full set of propertys for those objects.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Well about SLK file I asked for if I make a system with too much dummy abilities (like a bonus system) I dont want to annoy people (WHAT ???) with coppying dummies, and I thought I could put them in a SLK file and make them just import that instead of coppying dummies...
Umm you got what I mean.

I tought so Poot... Thanks
Uh I tought static is... anyway you know what I tought. Thanks Earth
 
Status
Not open for further replies.
Top