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



Reply
 
Thread Tools Search this Thread
Old 01-11-2010, 09:45 AM   #61
Kueken
User
 
Join Date: Mar 2009
Posts: 149

Kueken will become famous soon enough (41)Kueken will become famous soon enough (41)

Default

SpellEvent got problems when used in struct's initializers.

Collapse Zinc:
static method onInit()
{
    BJDebugMsg("register");
    RegisterSpellEffectResponse(ID,onCast);
    BJDebugMsg("done");
}
crashes the thread, done is not displayed, while
Collapse Zinc:
function onInit()
{
    BJDebugMsg("register");
    RegisterSpellEffectResponse(ID,Data.onCast);
    BJDebugMsg("done");
}
works fine. However,
Collapse Zinc:
static method onInit()
{
    BJDebugMsg("register");
    RegisterSpellEffectResponse(0,onCast);
    BJDebugMsg("done");
}
works fine, too.

Also, I would like to pass an anonymous function as a response, but I guess there is no chance, right? Since this would require the register functions to take code instead of integers (or is there a way to convert code back to integer?)

Last edited by Kueken : 01-11-2010 at 09:50 AM.
Kueken is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 01-11-2010, 09:53 AM   #62
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,154

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

why would you want to use it in a struct initializer ??...
__________________
akolyt0r is offline   Reply With Quote
Old 01-11-2010, 09:59 AM   #63
Kueken
User
 
Join Date: Mar 2009
Posts: 149

Kueken will become famous soon enough (41)Kueken will become famous soon enough (41)

Default

Quote:
Originally Posted by akolyt0r
why would you want to use it in a struct initializer ??...
why not? I did all the initialization stuff for a spell in it's structs initializer. That way the only functions I have are the configuration functions, everything else is within the struct. Now I have to use the library initializer just for SpellEvent.

Also I see no reason why it should not work in a struct initializer (and why it works in a struct initializer when using 0 as ability id). If it should not be used in a struct initializer, it should be mentioned in the documentation.

Last edited by Kueken : 01-11-2010 at 10:24 AM.
Kueken is offline   Reply With Quote
Old 01-11-2010, 01:03 PM   #64
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

This is the kind of thing that would be fixed by Vex changing the way initialization works. Here is my post on the subject.
grim001 is offline   Reply With Quote
Old 01-11-2010, 06:27 PM   #65
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,154

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

Yeah it would be much better to ask Vex about Grims' wish instead of asking any author about making it possible to use it in struct initializers, since that would solve every problem at once.

Personally i dont even think that struct initializers are useful at all... (btw: does any other language has something similar ???)
ONE way to initialize stuff was fully sufficient !

E:
Additionally i dont think stuff like this belongs in struct initializers, this doesnt have ANY relation to objects of the struct
__________________

Last edited by akolyt0r : 01-11-2010 at 06:29 PM.
akolyt0r is offline   Reply With Quote
Old 01-13-2010, 03:17 PM   #66
Kueken
User
 
Join Date: Mar 2009
Posts: 149

Kueken will become famous soon enough (41)Kueken will become famous soon enough (41)

Default

Well, its a matter of taste. If I create a struct for a spell and want everything related to this spell to be within the struct, I think the register of the spell event does indeed have a relation to the struct objects.
If SpellEvent forces me to use the scope initializer instead, I am fine with it, but it should be mentioned somewhere.

Last edited by Kueken : 01-13-2010 at 03:19 PM.
Kueken is offline   Reply With Quote
Old 01-13-2010, 03:53 PM   #67
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Struct initializer are good for custom allocators, for example.
In more general when you need to initialize private/readonly members.
Troll-Brain is offline   Reply With Quote
Old 01-13-2010, 07:06 PM   #68
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,154

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

Quote:
Originally Posted by Troll-Brain
Struct initializer are good for custom allocators, for example.
In more general when you need to initialize private/readonly members.

Still they are not needed.
A static Init method called from scope initializer achieves excactly the same result.
And that way we would not have these problems.

Even Vex uses this method.
__________________
akolyt0r is offline   Reply With Quote
Old 01-13-2010, 07:41 PM   #69
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Since you have to declare a static method i don't see what's bad by simply declaring directly a struct initializer.
I'm agree the way how jasshelper handle initializers needs to be improved but we can't blame Vexorian for that.

I mean, i don't see any problem with struct initializers, it's more the way how jasshleper handle initializers which is strange.

Also many vJass stuffs are "not needed"

Last edited by Troll-Brain : 01-13-2010 at 07:50 PM.
Troll-Brain is offline   Reply With Quote
Old 01-14-2010, 12:57 AM   #70
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Version 1.1 fixes the bug that occured with instant abilities like Berserk and Wind Walk. Such spells will now no longer conflict with SpellEvent as long as the spells have zero casting time.
__________________
Anitarf is offline   Reply With Quote
Old 01-14-2010, 03:19 PM   #71
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by Anitarf
Version 1.1 fixes the bug that occured with instant abilities like Berserk and Wind Walk. Such spells will now no longer conflict with SpellEvent as long as the spells have zero casting time.
Does it means that we can't use such not instant spell without triggering the casting time ?

EDIT : I mean will you fix it , in other words is it just a temp fix or a "definitive one"?

Last edited by Troll-Brain : 01-14-2010 at 03:55 PM.
Troll-Brain is offline   Reply With Quote
Old 01-14-2010, 04:04 PM   #72
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,154

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

I think you understood anitarf ?
Quote:
Originally Posted by Troll-Brain
Does it means that we can't use such not instant spell without triggering the casting time, or having casting time zero for that spell ?
__________________
akolyt0r is offline   Reply With Quote
Old 01-14-2010, 04:14 PM   #73
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by akolyt0r
I think you understood anitarf ?
I think youv'e missed the edit ?
Troll-Brain is offline   Reply With Quote
Old 01-15-2010, 08:55 PM   #74
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

This is a "final" fix, I do not intend to support spells based on Berserk or Wind Walk that have a casting time greater than 0. If you want your spells to have a casting time, use a different base spell.
__________________
Anitarf is offline   Reply With Quote
Old 10-26-2011, 02:48 PM   #75
BBQ
User
 
Join Date: May 2011
Posts: 85

Submissions (2)

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

Default

Some points that I'd like to make:
  1. Make this use trigger conditions (taken as a code parameter so that they don't have to return boolean). That will also allow the usage of anonymous functions (they can only be used with function pointers that take arguments - which is not the case here) and the registration of multiple responses per ability ID.
  2. Use a native hashtable instead of Table. That will allow you to initialize the system in a module and provide a separate module for structs, which would let the user declare methods such as onSpellCast and onSpellEffect that will run when the appropriate event is fired.
  3. Improve the initialization. I really see no reason not to inline everything in a single loop and use a condition instead of an action in the main trigger.
  4. Provide a constant to be used when registering a response for "any" ability. I think it'd be neater.

Last edited by BBQ : 10-26-2011 at 07:52 PM.
BBQ 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 12:39 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