Server Help

ASSS Questions - toggling images

tcsoccerman - Fri Mar 21, 2008 2:32 pm
Post subject: toggling images
some of the parameters in toggling images have me confused. especially paramters *id and *ons in Toggle() and ToggleSet(); Can anyone please clarify those for me?
Goldeye - Fri Mar 21, 2008 3:48 pm
Post subject:
Code: Show/Hide
void (*Toggle)(const Target *t, int id, int on);

The target's obvious, though apparently passing an arena changes the defaults not the active state for everyone there. <shrug>

id is the object id, on is boolean for whether it's on or not. 1=on 0=off.

Code: Show/Hide
void (*ToggleSet)(const Target *t, short *id, char *ons, int size);

This is a way of efficiently passing a lot of parameters to Toggle. Toggle probably would repeat stuff that only needs to be done once per target, so this way you can a set of objects without that inefficeincy.
id and ons are both arrays. size is the number of objects in that array.

Think of it (functionally, though the details inside are different, obv) as this:
Code: Show/Hide

void ToggleSet(const Target *t, short *id, char *ons, int size)
{
   int i;
   for(i=0;i<size;i++)
   {
      Toggle(t,id[i],ons[i]);
   }



Example:
This code turns on objects 3 and 2 and turns 7 off.
Code: Show/Hide

short id = { 3, 7, 2 }
char ons = { 1, 0, 1}
size = 3;
objects->ToggleSet(t, id, ons, size);

tcsoccerman - Fri Mar 21, 2008 3:55 pm
Post subject:
Very nice example. I never realized the relation between id and ons. obviously they correspond. Thank You!
Bak - Fri Mar 21, 2008 10:20 pm
Post subject:
I think they call them parallel arrays.

Code: Show/Hide
short id[] = { 3, 7, 2 };
char ons[] = { 1, 0, 1 };
objects->ToggleSet(t, id, ons, sizeof(id) / sizeof(id[0]));

tcsoccerman - Fri Mar 21, 2008 10:27 pm
Post subject:
oh ok.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group