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

[JASS] Code / Codestack (vJass)

Status
Not open for further replies.
Level 28
Joined
Jan 26, 2007
Messages
4,789
Hey,

I am wondering what the variables "Codestack" and "code" are for.
I've never heard of it, or seen it before...


JASS:
public method register takes code c returns nothing
    set .stackCode = CodeStack.create(c, .stackCode)
    set .stackCode.taInlet = TriggerAddAction(.trigInlet, c)
    set .stackCode.taFilter = TriggerAddAction(.trigFilter, c)
endmethod
Also, this looks a lot like the well known return bug, but it takes a code instead of a handle.
(This might be the reason why it doesn't work in v1.24).

JASS:
private static method C2I takes code c returns integer
    return c
    return 0
endmethod

JASS:
private static method I2UC takes integer i returns code
    return i
    return null
endmethod

I have no idea how to fix this (if it is a problem).
Well, I don't get vJass, but just wanted to fix this, since I want this map to work with v1.24.
If there are any other possible reasons why this won't work with 1.24, please say so.
(anyhting that has to do with vJass if possible ^^)

I couldn't see this in any tutorial or other post as well, so I just posted it here ;)

Thanks in advance.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
CodeStack isn't a native type so I have no idea what it does.

code is basically a reference to any function in your map or in Blizzard.j and common.j. For example:
JASS:
function CodeTest takes nothing returns nothing
    local code c1 = function DoNothing
    local code c2 = function CodeTest
    local code c3 = function SquareRoot
endfunction
All of the above are valid uses of the code type.

And indeed, your script isn't compiling because of that code return bug. It's in fact that return bug only which should have been removed from Wc3. The others are harmless.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
CodeStack isn't a native type so I have no idea what it does.

code is basically a reference to any function in your map or in Blizzard.j and common.j. For example:
JASS:
function CodeTest takes nothing returns nothing
    local code c1 = function DoNothing
    local code c2 = function CodeTest
    local code c3 = function SquareRoot
endfunction
All of the above are valid uses of the code type.

And indeed, your script isn't compiling because of that code return bug. It's in fact that return bug only which should have been removed from Wc3. The others are harmless.

Thanks a lot... this helped out a real bunch.
Only 2 questions remain: why would you use codes if it is just a reference to an already existing code?
And how to fix the return bug? (since it isn't a handle, GetHandleId would be wrong, right?)
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
You can't fix that specific return bug case, and for a reason. That simple function could run any arbitery byte-code (which I never understood anyway), which technically gives you full control over what your map can do.

So, no, you can't fix that. And if your code uses that, it probably shouldn't be fixed anyway for your own safety.
 
Level 11
Joined
Apr 29, 2007
Messages
826
@ GhostWolf
It works by generating code from integers. I'm sure you know how code compiles, into a load of binary numbers. Basically, I2C let you make a code function from numbers. You could then execute that code with ExecuteFunc and do anything with the host computer, including putting viruses on it.

Takes like 1000 lines to do, though, so doing that is really a pain in the ass.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Aye, that's painful... it was a code from an awesome map.
It was a TD where you needed power (like in... electricity) to make your towers work, then you had to build power plants and you could select up to 8 towers for that power plant to give power to (of course, it has it's limit... you also can't distribute too much power from a newbie power plant to good towers), you had to start an entire network of power lines and plants to give power to the towers, to kill the creeps...

Basically: I knew it was going to be hard, but I didn't expect this...

Element of Water: you say there is a solution, can you please explain it somehow?
I would really like this to work.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Why would you ever need to abuse the return bug for that?
Woah, I didn't do it o_O
If I would've done it, I would understand what it did, lol...

Erm, since I'm not really sure what part you need, here is the map I got it from:
(small disclaimer: the map is unprotected, yet you have no permission to upload or distribute this map)
 

Attachments

  • Power Towers v1.25b.w3x
    323.8 KB · Views: 56
Status
Not open for further replies.
Top