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 > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 05-28-2010, 11:45 PM   #1
MasterofSickness
User
 
MasterofSickness's Avatar
 
Join Date: Feb 2006
Posts: 218

MasterofSickness is on a distinguished road (23)

Default RctAr[1] = gg_rct_1 ... AutomaticSetup?!

What I mean is the setup of the manually created regions in WE (in Jass they are rect) with a global array. I used to make this the whole time manually, but in fact I was always looking for an automation routine, like you can reread here:
Reference to old thread from 2006.
People like Vex said that I should keep making array references manually. Finally he gave me a good hint which I followed (setting up the huge list of code with an external text editor and just paste it in WE)... till now.
I got a relapse
From restarting my map again and again (for several different reasons each time) this manual setup of regions strained my nerves.
Always this same procedure...
Collapse JASS:
set RectAr[1]=gg_rct_1
set RectAr[2]=gg_rct_2
set RectAr[3]=gg_rct_3
Then either I had too many region declarations or too less or there were interrupts.

Now my current workarround (WITH THE HELP OF THE RETURN BUG 2.0).
I want to know what you think of it (besides that most of you are right when they say that the manual method nevertheless is well enough) and if I create any leaks that could harm the later game...

Collapse JASS:
library CustomScriptCode

globals
    private hashtable ht = InitHashtable()
endglobals

function RctId2Rct takes integer RctId returns rect
    call SaveFogStateHandle(ht, 0, RctId, ConvertFogState(RctId)) //Save RectId to HandleId
    return LoadRectHandle(ht, 0, RctId) //Load HandleId and return Rect
endfunction

endlibrary

Collapse JASS:
library Waypoints initializer Init //"initializer Init" for libraries & scopes if they should run at init

globals
    rect array RctAr
endglobals

private function Init takes nothing returns nothing //1 function called Init to run appropriate code
local integer i = GetHandleId(gg_rct_1) //should be 1048596
local integer A = 0

//Manual Setup:
//set RctAr[1]=gg_rct_1
//set RctAr[2]=gg_rct_2
//set RctAr[3]=gg_rct_3
//...

//Test: Get Rect IDs
//set i = GetHandleId(gg_rct_1)
//set s = I2S(i)
//call BJDebugMsg("1048596 = " + s) //fits!
//set i = GetHandleId(gg_rct_2)
//set s = I2S(i)
//call BJDebugMsg("1048597 = " + s) //fits!

loop
    exitwhen A == 56
    set A = A + 1
    set RctAr[A]=RctId2Rct(i)
    set i = i + 1
endloop
endfunction

endlibrary

This is just for the 56 first waypoints.
I will work it out after this consulting with you.
I tested it and it seams to work flawlessly.

So,
should I nullify or destroy anything or code anything in another way (I want an automated setup! ;) )
Thanks for all hints!

Last edited by MasterofSickness : 05-29-2010 at 11:20 AM.
MasterofSickness is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 05-29-2010, 07:13 AM   #2
PurgeandFire111
User
 
PurgeandFire111's Avatar
 
Join Date: Dec 2006
Posts: 253

PurgeandFire111 will become famous soon enough (58)PurgeandFire111 will become famous soon enough (58)

Default

Haha, that is a cool technique! I never thought of that.

Anyway, some small things:
Collapse JASS:
function RectId2HandleId takes integer RectId returns nothing
    //local integer i = RectId
    call SaveFogStateHandle(ht, 0, RectId, ConvertFogState(RectId)) //use it directly
endfunction

And:
Collapse JASS:
local integer i = GetHandleId(gg_rct_1) //just set it on declaration

Other than that it is fine. Awesome technique, I'll have to keep that in mind. :P

You can destroy the hashtable when you are done though. [if you aren't using it anymore]

EDIT: You can also merge the 2 functions into just 1. It won't be that naming-friendly (lol Rect2I_I2Rect), but that shouldn't matter much. [unless the JassHelper inlining applies to those functions]

Last edited by PurgeandFire111 : 05-29-2010 at 07:22 AM.
PurgeandFire111 is offline   Reply With Quote
Old 05-29-2010, 07:13 AM   #3
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default

So saving the fogstate converts the integer back into a handle? That's awesome!

I'm wondering what you're doing by increasing the handle index by one each time? Is that because you know for sure that your pre-made rects are each seperated by an index of 1?
Bribe is offline   Reply With Quote
Old 05-29-2010, 07:26 AM   #4
PurgeandFire111
User
 
PurgeandFire111's Avatar
 
Join Date: Dec 2006
Posts: 253

PurgeandFire111 will become famous soon enough (58)PurgeandFire111 will become famous soon enough (58)

Default

Quote:
Originally Posted by Bribe
So saving the fogstate converts the integer back into a handle? That's awesome!

Pretty much -> [Snippet] Typecasting

Finally a use for the new typecasting aside from the widget typecasting. xD

Quote:
Originally Posted by Bribe
I'm wondering what you're doing by increasing the handle index by one each time? Is that because you know for sure that your pre-made rects are each seperated by an index of 1?

Yep, the ones made on the editor are made consecutively in a function on map Init. Thus, they should have intervals of 1 for their ids.
PurgeandFire111 is offline   Reply With Quote
Old 05-29-2010, 10:07 AM   #5
MasterofSickness
User
 
MasterofSickness's Avatar
 
Join Date: Feb 2006
Posts: 218

MasterofSickness is on a distinguished road (23)

Thumbs up

@ PurgeandFire111
Thanks for the improvements!
I will change it like you said and perhaps merge it into 1 function :)

And thanks for the praise ;)
But without weaaddar it would not have been possible for me (convertfogstate)!

EDIT
Updated 1st post with appropriate improvements!

Last edited by MasterofSickness : 05-29-2010 at 11:21 AM.
MasterofSickness 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 09:06 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

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