HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

need help to build my own preprocessor

06-28-2009, 02:33 PM#1
Troll-Brain
I want to emulate a Wait usable like PolledWait() without its drawbacks (inaccurate, not nulling timer local variable, and totally avoid TriggerSleepAction, because of its drawbacks (not stopped when the game is paused, can't be used in a boolexpr) ).

The result will be a bloat vJass code, but i don't care, i don't want the most efficiency possible, just be friendly user.

Let's give an example :

Expand JASS:

Should be replaced by :

Expand JASS:

So first is it possible without editing the vJass preprocessor itself ?
Because i don't want touch it, and neither recode all vJass features ...

I perfectly know :
- The code must be in a scope or a library, but it's not a problem for me.
- local array are not supported yet, i think i will use hashtables.
- events responses Get... won't work after a Wait, i will declare them in the struct later.
- i've to declare an empty Wait function that takes a real r and returns nothing, and place it on the top of the script, just after the globals declaration, and i need to place the library KT to be the first.
- I could reduce the numbers of evaluates, if i handle better the position of the functions.
06-28-2009, 04:46 PM#2
Vexorian
If you want to do it correctly, it is tougher than compiling structs, that's for sure.

If you just want to pull out a hack then I guess you could even do something as dumb as compiling your waits to Mad[lion]'s timing system:
http://www.wc3c.net/showthread.php?t=101988
06-28-2009, 04:55 PM#3
Troll-Brain
Textmacros ...

It doesn't help me. I just want to know if i can make a vJass version of the code and let JassHelper do the jass compilation or if i need to edit your preprocessor.
06-28-2009, 04:58 PM#4
Vexorian
Please read that again, you could compile your wait call into those textmacros.
06-28-2009, 05:00 PM#5
Troll-Brain
Quote:
Originally Posted by Vexorian
Please read that again, you could compile your wait call into those textmacros.
Please read again my first post, i want something friendly user, and textmacros are all but not friendly user, in fact they are ugly ...
06-28-2009, 06:26 PM#6
PitzerMike
Quote:
Originally Posted by Troll-Brain
Quote:
Originally Posted by Vexorian
Please read that again, you could compile your wait call into those textmacros.
Please read again my first post, i want something friendly user, and textmacros are all but not friendly user, in fact they are ugly ...

See, if you compile the code into textmacros that doesn't mean the user has to deal with textmacros.
06-28-2009, 07:37 PM#7
Troll-Brain
I'm lost
Could you give an example plz ?

Or maybe i'm not enough clear, and you don't understand what i want.
06-29-2009, 01:05 PM#8
snowtiger
well, you make your compiler compile call wait(x) into //!runtextmacro wait(x)
06-29-2009, 08:55 PM#9
Strilanc
This is relatively simple in principal. You turn all local variables into struct variables, and turn the function into a state machine. When the function is called you allocate a struct, then pass that to the actual worker function. The worker function looks at the struct, sees that it is in state 0, and starts from the beginning.

The hard part is that for a real wait you also need to rewrite the CALLING function, and ITS calling function and so on. Otherwise they will just finish without waiting, even though your method is now on a timer. That is going to be painful, especially if you want to deal with cases where the function is called indirectly, eg. with TriggerEvaluate or ExecuteFunc.

I really don't think you're going to be able to deal with the recursive waiting case.
07-03-2009, 07:23 PM#10
Troll-Brain
Quote:
Originally Posted by snowtiger
well, you make your compiler compile call wait(x) into //!runtextmacro wait(x)
For what i want i can't use textmacros like that.

Quote:
Originally Posted by Strilanc
This is relatively simple in principal. You turn all local variables into struct variables, and turn the function into a state machine. When the function is called you allocate a struct, then pass that to the actual worker function. The worker function looks at the struct, sees that it is in state 0, and starts from the beginning.

The hard part is that for a real wait you also need to rewrite the CALLING function, and ITS calling function and so on. Otherwise they will just finish without waiting, even though your method is now on a timer. That is going to be painful, especially if you want to deal with cases where the function is called indirectly, eg. with TriggerEvaluate or ExecuteFunc.

I really don't think you're going to be able to deal with the recursive waiting case.

I don't really see the problem, but i haven't try recursive waits yet, thought.
07-08-2009, 04:01 AM#11
Strilanc
Let me give an example of what I mean, in partial pseudo code.

Collapse JASS:
function Waiter takes nothing returns nothing
  print "2"
  wait for 3 seconds
  print "3"
endfunction
function Caller takes nothing returns nothing
  print "1"
  call Waiter()
  print "4"
endfunction

A correct wait will cause the output to be 1, 2, 3, 4. A partially correct wait will cause the output to be 1, 2, 4, 3.
07-08-2009, 03:19 PM#12
Troll-Brain
Then i simply need to handle functions like i handle if/then/else blocks.
02-09-2011, 09:17 PM#13
Troll-Brain
Ok i'm able to edit the function compile_map(path) of the wehack.lua in order to launch a personal .exe which can modify a text file (war3map.j).
However it seems that the file "war3map.j" in the JNGP folder is here only as a log, editing it before jasshelper process does nothing.

Actually i sadly haven't enough skills to find the solution myself.

Is there a simple dirty solution like inject the modified war3map.j in the map before the jasshelper process ? And how can i do it if it's possible ?
(wehack.injectfile or something ?)
02-10-2011, 08:11 PM#14
Troll-Brain
Nevermind it was so easy, after reading the jasshelper documentation.
Sorry for that i was watching about grimoire instead ><

Quote:
If instead of three arguments you pass four file arguments to the program, the behavior changes:

jasshelper.exe <path_to_common.j> <path_to_blizzard.j> <path_to_mapscript.j> <path_to_map.w3x>

It will ignore the map's script file, and instead consider the given script file as the vJass source. Since the 3 files syntax removes the original vJass source code from the map, this method is more useful, you can generate the source map by exporting the map's script from the editor. (Hint: Use //! import and //! novjass in combination to command line jasshelper and World Editor)