System Rectwraps

Azlier

Old World Ghost
Reaction score
461
I still don't see how it would help. At all. You would have to attach the struct to the handle to make it work as it should.
 

Azlier

Old World Ghost
Reaction score
461
Would simplify syntax, indeed. But you still need to attach the struct to the region and/or rect.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Hm. Depends how it's implemented, then. He may be right. We'll have to wait and see.

Because "extending handles" to me, means instead of an integer index, it will be a real handle, so its kind of like a thin wrapper. Which wouldn't help here, I imagine. But this wouldn't allow struct members. If it's implemented as "rect" becomes an integer, and JassHelper automatically reads rect.actualRect or whatever, then yes, this could work with it. But at the end of the day, this must pass around an integer. :)
 

Azlier

Old World Ghost
Reaction score
461
Optional, alternate interfaces are now available. Just like the one in Trackable2.
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
    method registerEnter takes trigger whichTrigger, rectwrap which returns nothing
        local region reg = CreateRegion()
        local trigger t = CreateTrigger()
        local Cache c = Cache.create()
        local RegionList r = RegionList.create()
        set c.toFire = Event.create()

This can't be right... can it? A new event for every registration? Shouldn't it be one event per region? Did I miss something? >_>
 

Azlier

Old World Ghost
Reaction score
461
Is it? I really don't remember it anymore. Oh, wait. Yesss. Now I remember. If you don't create a new event for each rect, it runs the trigger as many times as how many rects you registered.

Anyway, what are the RegionLists for? I forget.

EDIT: Ahhh, yes. RegionLists are there to clean things up after struct destruction. Riiight.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Lol err... I'm pretty sure you butchered this somewhere along the line. The idea of Event is you don't know how many triggers will be attached. The way you've used it, only one can be attached. But if you wanted two triggers to trigger off entering the same rect or region, it should add to the same event... <_<?

But it doesn't?

May be time to rewrite this from scratch using your new experience if you can't remember how it works... XD :p
 

Azlier

Old World Ghost
Reaction score
461
Maybe I should just trash the event and store the trigger. Yes.

EDIT: Done. Oh, and Event is no longer needed. Efficiency gain, too.
 

Azlier

Old World Ghost
Reaction score
461
Total rewrite.

There is now only one body, the rectwrap. The system is now much more efficient, it actually works dynamically (better than the natives, in fact). The code is also shorter. Rects, regions, and triggers are also recycled. Today is a good day for rectwraps. Just needs some heavy testing. It passed my light testing.

Could someone change the thread title to Rectwraps, please? There is no R&R. Not anymore.

Requires Event once again.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Hey, I actually read through it! You seem to have done it correctly this time 'round. Well done, credits to you. The code is nicely commented and was actually nice to read! :thup:

You don't need to set TrigRec to 0 or whatever I think. In your event-firing triggers. That's about it.

Well done. This actually looks quite usable and neat now. :D
 

Azlier

Old World Ghost
Reaction score
461
>You don't need to set TrigRec to 0 or whatever I think.
I do if I want it to behave like a true WC3 event. If I called it somewhere random in, say, a timer callback, I would get the last triggered rectwrap. Kind of weird to have around.
 

Azlier

Old World Ghost
Reaction score
461
Update. The wrap method now works with a copy of the rect, preventing possible bugs with the recycler and prevents the user from messing with the rect directly.
 

Azlier

Old World Ghost
Reaction score
461
There is a constructor that takes reals. It's .create. .wrap just takes an existing rect, making gg_rct rects easy. Don't think I haven't thought this over.
 

Azlier

Old World Ghost
Reaction score
461
Well, it used to toss the rect you gave it into the recycler. Which means modifying the rect at a later time could ruin a random rectwrap within the system. Also, it overwrote anything else that might be in there, causing a memory leak. Copying the rect is safer and memory leakless (except in the case of the original rect, which the user may destroy or use more).
 

Azlier

Old World Ghost
Reaction score
461
Does anybody find this useful? Or is it just me? It's one of the things I made that I actually use :p.
 

Azlier

Old World Ghost
Reaction score
461
Meh. Alternate interface exists once more, for EGUI (should Sevion want rectwraps in there) and those who don't know structs.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top