Ejemplo n.º 1
0
void conn_delete_by_desc(DESC_DATA *d)
{
	CONN_MAP::iterator	iter, cur_iter;

	for (iter = s_conn_map.begin(); iter != s_conn_map.end(); )
	{
		cur_iter = iter; iter++;

		CONN_DATA	*conn = cur_iter->second;

		if (GET_DESC(conn) == d)
		{
			s_conn_map.erase(cur_iter);
			account_logout(conn);


			if (GET_EVENT(conn))
			{
				event_cancel(GET_EVENT(conn));
				GET_EVENT(conn) = NULL;
			}
			SAFE_FREE(conn);
		}
	}
}
bool EVENT_EventIsSetAutoClear(EVENT_Handle event) {
  bool res;

  res = GET_EVENT(event);
  if (res) {
    CLR_EVENT(event); /* automatically clear event */
  }
  return res;
}
Ejemplo n.º 3
0
bool EVNT_EventIsSetAutoClear(EVNT_Handle event) {
	bool res;
	CS1_EnterCritical();
	res = GET_EVENT(event);
	if (res) {
		CLR_EVENT(event); /* automatically clear event */
	}
	CS1_ExitCritical();
	return res;
}
Ejemplo n.º 4
0
void conn_delete(DWORD account_id)
{
	CONN_MAP::iterator	iter;

	iter = s_conn_map.find(account_id);

	if (iter==s_conn_map.end())
		return;
	CONN_DATA	*conn = iter->second;
	s_conn_map.erase(iter);

	sys_log("CONN_DELETE : %d, %s", GET_ID(conn), GET_LOGIN(conn)?GET_LOGIN(conn):"null");

	if (GET_EVENT(conn))
	{
		event_cancel(GET_EVENT(conn));
		GET_EVENT(conn) = NULL;
	}
	account_logout(conn);
	SAFE_FREE(conn);
} 
void EVENT_HandleEvent(void (*callback)(EVENT_Handle)) {
  /* Handle the one with the highest priority. Zero is the event with the highest priority. */
   EVENT_Handle event;
   CS1_CriticalVariable();

   CS1_EnterCritical();
   for (event=(EVENT_Handle)0; event<EVENT_NOF_EVENTS; event++) { /* does a test on every event */
     if (GET_EVENT(event)) { /* event present? */
       CLR_EVENT(event); /* clear event */
       break; /* get out of loop */
     }
   }
   CS1_ExitCritical();
   if (event != EVENT_NOF_EVENTS) {
     callback(event);
     /* Note: if the callback sets the event, we will get out of the loop.
      * We will catch it by the next iteration.
      */
   }
}
Ejemplo n.º 6
0
}

void EVNT_ClearEvent(EVNT_Handle event) {
  CS1_CriticalVariable()

  CS1_EnterCritical();
  CLR_EVENT(event);
  CS1_ExitCritical();
}

bool EVNT_EventIsSet(EVNT_Handle event) {
  CS1_CriticalVariable()
  bool res;

  CS1_EnterCritical();
  res = GET_EVENT(event);
  CS1_ExitCritical();
  return res;
}

bool EVNT_EventIsSetAutoClear(EVNT_Handle event) {
  CS1_CriticalVariable()
  bool res;

  CS1_EnterCritical();
  res = GET_EVENT(event);
  if (res) {
    CLR_EVENT(event); /* automatically clear event */
  }
  CS1_ExitCritical();
  return res;
bool EVENT_EventIsSet(EVENT_Handle event) {
  return GET_EVENT(event);
}
Ejemplo n.º 8
0
bool EVNT_EventIsSet(EVNT_Handle event) {
	CS1_EnterCritical();
	bool tmp = GET_EVENT(event);
	CS1_ExitCritical();
	return tmp;
}
Ejemplo n.º 9
0
int input_login(DESC_DATA *d, const char *data, int plen)
{
	const int	PACKET_LENGTH = 4;

	if (plen < PACKET_LENGTH)
		return 0;

	DWORD	account_id = decode_4bytes((const BYTE*)data);

//	sys_log("LOGIN: %u", account_id);

	/* 기존 정보가 있으면 접속을 끊으라고 알려줌 */
	CONN_DATA	*conn = conn_find(account_id);
	if (conn)
	{
		send_force_logout(conn);
		//conn_delete(GET_ID(conn));

		// 새로운 접속자도 접속을 끊는다.
		{
			PACKET_DATA	*buf = &d->packet_buffer;

			packet_header(buf, HEADER_TG_FORCE_LOGOUT, d->desc_num);
			packet(buf, GET_LOGIN(conn), MAX_LOGIN_LEN);
		}
		return PACKET_LENGTH;
	}

	conn = (CONN_DATA*) calloc(1, sizeof(CONN_DATA));
	GET_ID(conn)	= account_id;
	GET_DESC(conn)	= d;
	GET_EVENT(conn)	= NULL;


	int login_succ = FALSE;
	if (teen_all_flag)
		login_succ = account_login_teen_all(account_id, conn);
	else
		login_succ = account_login(account_id, conn);

	if (FALSE==login_succ)
	{
		//conn_delete(GET_ID(conn));
		SAFE_FREE(conn);
		return PACKET_LENGTH;
	}

	conn_insert(conn);

	if (YES==GET_TEENAGE(conn))
	{
		conn_event_info	*info = (conn_event_info*) calloc(1, sizeof(conn_event_info));
		info->conn = conn;
		GET_EVENT(conn) = event_create(conn_event_func, info, (CHECK_TIME_SEC * PASSES_PER_SEC));
	}
	else
	{
		GET_EVENT(conn) = NULL;
	}

	if (YES==GET_TEENAGE(conn))
	{
		send_login_notice(conn);
		set_notice_step(conn);
		send_notice(conn);
	}

	sys_log("CONN_INSERT : %u, %s", GET_ID(conn), GET_LOGIN(conn));

	return PACKET_LENGTH;
} /* end of input_login() */