| 01-07-2008, 12:32 AM | #1 |
I am in the process of making a system which randomly generates rooms; it similar to SWAT: Aftermath. As part of the system, i plan on using the executefunc function to generate a type of room. This mean i will have many different room type functions strings that needs to match with its proper identification integer. So my solution to the problem was to put the function name a string array. However, i was wondering - when i use vexorian's map optimizer, does it link the string name (which is in an array) to the newly generated "shortest possible function name"? Let me explain: I somewhat read vexorian's readme.txt and i assume that this works properly: JASS:function ThisIsAFunctionName takes nothing returns nothing endfunction function ThisFunctionExecutesAnotherFunction takes nothing returns nothing call ExecuteFunc("ThisIsAFunctionName") endfunction //========================================= After Map Optimization function AA takes nothing returns nothing endfunction function AB takes nothing returns nothing call ExecuteFunc("AA") endfunction My question however pertains when the argument is from a (array) variable: JASS:globals string functionName = "ThisIsAFunctionName" //should actually be an array endglobals function ThisIsAFunctionName takes nothing returns nothing endfunction function ThisFunctionExecutesAnotherFunction takes nothing returns nothing call ExecuteFunc(functionName) endfunction //========================================= After Map Optimization & what i expect/need it to do globals string functionName = "AA" //should actually be an array endglobals function AA takes nothing returns nothing endfunction function AB takes nothing returns nothing call ExecuteFunc(functionName) endfunction So back to my question: will the map optimizer change the variable functionName to match the "Use the shortest function name string as possible" during optimizing? --- Also, does the "shortest function name" also apply to global variable names - it would be nice? |
| 01-07-2008, 01:17 AM | #2 |
Use triggers and triggerevaluate/execute instead and save yourself the ExecuteFunc headache. |
| 01-07-2008, 01:23 AM | #3 | |
Quote:
But doesn't that i mean i have to create a trigger for each function and then add its action (not that i'm too concern with it)? Can you/anyone else think of any other alternatives? |
| 01-07-2008, 01:30 AM | #4 |
JASS:function interface roomFunction takes nothing returns nothing function room1 takes nothing returns nothing call BJDebugMsg("1") endfunction function room2 takes nothing returns nothing call BJDebugMsg("1") endfunction globals roomFunction array rooms integer N=0 endglobals function setRooms takes nothing returns nothing set rooms[0]=roomFunction.room1 set rooms[1]=roomFunction.room2 set N=2 endfunction function randomRoom takes nothing returns nothing local integer i=GetRandomInt(0,N-1) //call rooms[i].evaluate() --if you do not need waits on it call rooms[i].execute() //if you need waits endfunction |
| 01-07-2008, 01:30 AM | #5 |
function interfaces using jasshelper. It basically does the 'create a trigger for each function and then add its action' for you, and is "as far as we currently know" the fastest and most efficient way of doing it. |
