Server Help

ASSS Questions - It would be great to...

Bak - Tue Aug 02, 2005 9:15 pm
Post subject: It would be great to...
It would be great to be able to allocate per player or per arena data with an arena paramenter. One use would be saving space by only allocating memory for arenas where a module is attached, so a subarena with a few hundred bytes of player data doesn't have to allocate that much for every player. It would complicate the way data is stored, but I'm sure there's a way to do it. Also if net could have an arena paramenter on AddPacket and RemovePacket that would be good, so I don't have to allocate arena data to tell me whether the module is attached or not.
Dr Brain - Tue Aug 02, 2005 10:12 pm
Post subject:
Memory is cheap. Don't fret over it. A few hundred bytes is a drop in an ocean.

As for the attached thing, it might just be simpler to get a function in the module manager. Something along the lines of

Code: Show/Hide

mm->IsAttached("mymodule", arena);


because net packets aren't the only time you want to check if you're attached.
Cyan~Fire - Wed Aug 03, 2005 10:23 am
Post subject:
Dr Brain wrote:
Memory is cheap. Don't fret over it. A few hundred bytes is a drop in an ocean.

Still, there's not point in wasting it.
Grelminar - Wed Aug 03, 2005 5:23 pm
Post subject:
The whole point of the per-arena/per-player data stuff is specifically to avoid separate allocation, so there's no way they'll be changed to do this. What you can do, though, is to allocate room for a pointer to your private data in the per-arena space, and then allocate a larger chunk of space manually. E.g.:

Code: Show/Hide
typedef struct my_adata { ... } my_adata;
int MM_foo(...) {
  if (action == MM_LOAD) {
    adkey = aman->AllocateArenaData(sizeof(my_adata *));
  } else if (action == MM_ATTACH) {
    my_adata **adp = P_ARENA_DATA(arena, adkey);
    *adp = amalloc(sizeof(**adp));
  } else if (action = MM_DETACH) {
    my_adata **adp = P_ARENA_DATA(arena, adkey);
    afree(*adp);
  }
  ...
}


Then you can check whether the pointer in the arena data is null or not to see if you're attached to the arena.

Note that this is described in the developer guide, section 5.4.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group