Multiple struct > Struct array members?

XeNiM666

I lurk for pizza
Reaction score
138
Its a simple question, supposed i am to create a nova of 16 fireballs. Should i use 16 multiple structs to handle each fireball? or should i use 1 struct with 16 multiple array members to handle the fireballs? in terms of efficiency and speed.
TIA. :)
 

tooltiperror

Super Moderator
Reaction score
231
I don't understand the question. What are you trying to achieve?
 

XeNiM666

I lurk for pizza
Reaction score
138
the nova is just an example... let me explain...
supposed i am to create a nova of 16 fireballs in my location. What should i use to achieve more efficiency and speed.
Should i use multiple structs:
JASS:
    private struct Fire
        unit u
        real x
        real y
        bla bla bla
        
        static method create takes bla bla bal
        endmethod
    endstruct
    
    function Action takes nothing returns nothing
        local integer i = 0
        local Fire f
        loop
            set i = i + 1
            
            set f = Fire.create( x, y, bla bla bla )
            
            exitwhen i >= 16
        endloop
    endfunction

Or should i use 1 struct with array members:
JASS:
    private struct Fire
        unit u
        real x
        real y
        
        unit array fire [ 16 ]
        real array cos [ 16 ]
        real array sin [ 16 ]
        bla bla bla
        
        static method create takes bla bla bla
            local Fire f = Fire.allocate()
            local integer i = 0
            loop
                set i = i + 1
                set f.fire[ i ] = CreateUnit( ... )
                set f.sin[ i ] = Sin( ang )
                set f.cos[ i ] = Cos( ang )
                
                exitwhen i >= 16
            endloop
            
            return f
        endmethod
    endstruct
    
    function Action takes nothing returns nothing
        local Fire f = Fire.create( x, y, bla bla bla )
    endfunction
 

tooltiperror

Super Moderator
Reaction score
231
So you are creating fire effects? Why do you need to use a struct at all? Why don't you just create them directly?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
In terms of efficiency and speed, it's going to be negligible. However, in terms of what's "best", it depends on what your fireballs are.

If they are simply projectiles or units, it might be best to have a struct for the general definition of projectile or unit.

If you plan on having MANY of these spell instances going up at once, it should be noted that having an array as a member of a struct limits the number of instances of the struct to 512 (8192/16).

Also, using a separate struct for the fireballs would allow you to use a linked-list style method of iterating over the fireballs, which may or may not be favorable to you. If you only iterate in order from fireball 1 to 16, then it won't make any difference whether you use linked lists or arrays. However, if you happen to need a specific fireball at any point in time, it will be less efficient to use the linked list.

All in all, it should just be whatever you think is the best way to do it.
 

XeNiM666

I lurk for pizza
Reaction score
138
no. im using struct to do something with them... in my case, revolving them around the caster and move them to the casters position after some duration.. so?

EDIT:
I see.. Im not fond of linked lists so array will do. Since they are almost the same right?
Thanks for the quick replies! :)
 

saw792

Is known to say things. That is all.
Reaction score
280
Ah but linked lists are so beautiful... and don't reduce your instance limit!

Lame :(
 

LurkerAspect

Now officially a Super Lurker
Reaction score
118
I've made several nova abilities like this before - what I do is create a struct system for a single projectile, then I use a loop to generate as many "projectiles" as I need, and the struct works fine even with ~100 instances, and 0.02 interval, no lag whatsoever (aside from first cast lag of course). So I say make 16 separate fireballs, this makes it easier if the fireballs are supposed to hit other objects.
 

saw792

Is known to say things. That is all.
Reaction score
280
Of course, but then you can always recycle your instances :) I just like the flexibility of trees and linked lists :p
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I don't like the sized-array crap introduced by vJass.

JASS:

struct foo
 integer array guy[16]
 set this.guy[5] = 1

// Change that to...

integer array guy
set guy[this * 16 + 5] = 1

? What's wrong with it? I think that's what vJass does.

If you don't like it, the alternative is manually typing out that [ljass]this*16 + 5[/ljass] stuff.

JASS:
struct foo
    integer array bar[16]
    ...
    set this.bar[5] = 1
    ...
endstruct

//Alternatively:

globals
    integer array bar
endglobals

struct foo
    ...
    set bar[this * 16 + 5] = 1
    ...
endstruct


Almost a direct quote from you, but this is almost essentially what vJass does with structs, what syntax did you want? vJass arrays are limited by the same things as Jass.
 

Bribe

vJass errors are legion
Reaction score
67
vJass compiles it differently than what I posted, and I don't know why. It uses twice the array lookups.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Sticking with the desserts for now the latest recipe is Fried Apple Pies - https://www.thehelper.net/threads/recipe-fried-apple-pies.194297/
  • The Helper The Helper:
    Finally finding about some of the bots that are flooding the users online - bytespider apparently is a huge offender here - ignores robots.txt and comes in from a ton of different IPs
  • Monovertex Monovertex:
    @The Helper I'm really not seeing the "Signature" link in the sidebar on that page. Here's a screenshot:
  • The Helper The Helper:
    I have reported it - I was wondering why nobody I have given sigs to over the last few years have used them
  • The Helper The Helper:
    Ghan has said he has fixed this. Monovertex please confirm this fix. This was only a problem with people that had signatures in the upper levels like not the special members but the respected members.
  • The Helper The Helper:
    Here is a better place to manage this stuff https://www.thehelper.net/account/account-details which I think should be way more visible
  • The Helper The Helper:
    I am hoping that online user count drop is finally that TikTok bot banned
  • Ghan Ghan:
    I added the filter last night.
  • The Helper The Helper:
    They are still there

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top