• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

weathereffect handle loading

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,342
Hi,

So I read through the return bug tutorial, and unfortunately it says this:

The rest can't since there are no hashtable functions for them. However, this system can help fix that problem, for most of them (except weathereffect and terraindeformation ):

I need to cast a handle id into a weathereffect . How can I do this?
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
You can use a struct wrapper and use a hashtable for indexing, I guess.

JASS:
struct
 weathereffect wfx
 terraindeformation tfx
endstruct
 
Level 15
Joined
Aug 7, 2013
Messages
1,342
I want to save an instance of a weather effect so I can later destroy it.

i.e.

JASS:
call RemoveWeatherEffect(newTable.weathereffect[...])
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I can think of only this solution now.First you need to create a global weathereffect variable with array,
JASS:
globals
    weathereffect array WE
endglobals

Lets say you want to save a weather effect, instead of saving weather effect to hashtable directly, you will save its integer index of array.
 
Level 15
Joined
Aug 7, 2013
Messages
1,342
This I thought about Ceday, but if I want to bind the weather effect to another handle, e.g. a rect, then an array would get an out of bounds error most likely.

Why? Well weather should easily be turned on and off in a rect, because it's a rect field/property (high level). I think it's silly there's no natives that remove weather from a rect and also clean up the old handle. Or maybe I just didn't find it/look hard enough?

i.e. this is what I wanted to do

JASS:
call RemoveWeatherEffect(newTable.weathereffect[GetHandleId(myRect)])

I was thinking of creating a data structure like you mentioned to manage weather effects. My need is not huge anymore, since the solution I used retrieves the weather effect's instance by binding the rect handle to a struct.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Not sure how table works, but this should with hashtables I think, you can convert.You won't need more than 8000 weathereffects anyway.

JASS:
globals
    weathereffect array WEATHERS
    integer WEATHERINDEX = 0
endglobals

function SaveWeathereffect takes hashtable h, integer parent, integer child, weathereffect we returns nothing
    call SaveInteger(h, parent, child, WEATHERINDEX)
    set WEATHERS[WEATHERINDEX] = we
    set WEATHERINDEX = WEATHERINDEX + 1
endfunction

function LoadWeathereffect takes hashtable h, integer parent, integer child returns weathereffect
    return WEATHERS[LoadInteger(h, parent, child)]
endfunction

function DestroyWeathereffect takes hashtable h, integer parent, integer child returns nothing
    call RemoveWeatherEffect(LoadWeathereffect(h, parent, child))
endfunction
 
Status
Not open for further replies.
Top