Code: Show/Hide case EVENT_PlayerMove: { Player *p = (Player*)event.p[0]; if(inHill(p)) { if(p->team==0) { if(team0Players.find(p) == NULL) { team0Players.append(p); sendPublic("player entered hill"); } } else if(p->team==1) { if(team1Players.find(p) == NULL) { team1Players.append(p); sendPublic("player entered hill"); } } } else { //if not in hill if(p->team==0 && team0Players.find(p)!=NULL) { sendPublic("player left hill"); team0Players.kill(p); } else if(p->team==1 && team1Players.find(p)!=NULL) { sendPublic("player left hill"); team1Players.kill(p); } } } |
Code: Show/Hide _linkedlist <Player> team0Players; //team 0 players in the hill _linkedlist <Player> team1Players; //team 1 players in the hill |
Code: Show/Hide _linkedlist <Player> team0Players(true); //team 0 players in the hill
_linkedlist <Player> team1Players(true); //team 1 players in the hill |
Bak wrote: | |
arg, I forgot to look in the listnode destructor... good find samp (i guess this is why people hate c++). Looks like when you declare the linkedlist initializing it with true will prevent it from freeing the Players
|
Code: Show/Hide TEMPLATE void _linkedlist <AnonymousStruct>::unlist(AnonymousStruct *item)
{ copy = true; kill(item); copy = false; } |