Example #1
0
int LeaveChannel(user *User) {

   channel *Channel;

   if (User == NULL) {
      Error("LeaveChannel(): User = NULL");
      return FALSE;
   } else if (User->Type != USER) {
      Error("LeaveChannel(): \"%s\" couldn't leave \"%s\" (not a user)",User->Id,User->Channel);
      return FALSE;
   }

   Channel = SearchChannel(User->Channel);
   if (Channel == NULL) {
      Error("LeaveChannel(): \"%s\" couldn't leave \"%s\" (unknown channel)",User->Id,User->Channel);
      return FALSE;
   }

   Channel->UserNb--;
   if (Channel->UserNb < 0) {
      Error("LeaveChannel(): After \"%s\" left \"%s\", there were %d users in it",User->Id,User->Channel,Channel->UserNb);
      Channel->UserNb = 0;
   }
   if (Channel->UserNb == 0 && ! Channel->Resident) {
      RemObject(ChannelList,Channel);
      DeleteChannel(Channel);
   }

   strcpy(User->Channel,"");

   return TRUE;
}
Example #2
0
int __cdecl main()
{
	ChannelSearchInfo searchInfo;

	while(1)
	{
		::Sleep(200);		// Scan the channels every 200 secs
		
		bool succ = SearchChannel(&searchInfo);

		if (succ)
		{
			ProcessChannel(&searchInfo);
		}
	}

	return 0;
}