Algorithms: Optimize tile iteration

Started by abstauber, Mon 23/05/2011 11:04:28

Previous topic - Next topic

Calin Leafshade

I didn't even know you could create managed types in the script. I use a plugin to make all my utility types (like Point2D and Rectangle and so on).

So you can have a struct as a member of a struct? I thought this wasnt possible. Witchcraft!

(I agree with Wyz that it's almost certainly likely to be slower though due to all the abstraction required)

abstauber

oooooooOOOhh!  Thanks for pointing my nose on this. I totally underestimated that snippet!

That's witchcraft indeed. 


managed structs are nestable... yaytards!  :=

Khris

Ay caramba! :o

There's also "attribute" among those previously unknown to me keywords!
Is there some semi-official documentation about them floating around?

But dahamn! Nestable structs. Now we're talking.

monkey0506

#23
Okay, let's go back a bit here. RyanTimothy, unless you've done something to your AGS that you haven't told the rest of us about, that code example you posted does not work at all. It will compile fine because it looks valid, but you'd end up getting a Null-pointer referenced error as soon as you tried to use it.

You cannot currently create a pointer to a custom struct (outside the context of the this pointer within a member or extender method). It won't work. I've put a lot of work into testing the various functionality of the managed keyword (a lot of which would have CJ quivering to think of what I've been doing to his poor, innocent program in my dark, secret corner), but presently the only way you can create a pointer to a non-built-in struct is via the editor plugin API.

You can use the managed keyword if you're writing a module and just don't want people creating instances of a static struct, but beyond that it's pretty useless to the end-user within the AGScript language.

Edit: Regarding the attribute keyword, I wrote a bit about them, but it went away rather silently into the void.

Ryan Timothy B

#24
Haha I was worried there was going to be an issue with that.

Yeah, I'll admit I've never actually used nor tried to use the managed struct nested into another struct until I had seen Calin's post above. So I blame Calin. ;)
I checked if it would compile, it did, and said "damn, if only I knew that a year ago - damn that Calin guy is smart.." :P Didn't realize he was using a plugin until now.

And when I wrote "I've always done it this way", I meant I used to do it in this format (If I recall correctly) which is pretty much the same deal, no?:

Code: ags

struct sWhatever {
  int height_Y[50];
  bool visible_Y[50];
};
sWhatever whatever_X[20];

//----

whatever_X[1].height_Y[10] = 123;
whatever_X[1].visible_Y[10] = true;


So would this still be much slower than a struct array with 1000 indices?

Edit: Sorry for getting you guys excited. :P The whole asterisks pointing to the managed struct is what should have set off an alarm and made me wonder why that would actually work.

SMF spam blocked by CleanTalk