示例#1
0
static int chrif_reconnect(DBKey key,void *data,va_list ap)
{
	struct auth_node *node=(struct auth_node*)data;
	switch (node->state) {
	case ST_LOGIN:
		if (node->sd && node->char_dat == NULL)
		{	//Since there is no way to request the char auth, make it fail.
			pc_authfail(node->sd);
			chrif_char_offline_nsd(node->account_id, node->char_id);
			chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
		}
		break;
	case ST_LOGOUT:
		//Re-send final save
		chrif_save(node->sd, 1);
		break;
	case ST_MAPCHANGE:
		{	//Re-send map-change request.
		struct map_session_data *sd = node->sd;
		uint32 ip;
		uint16 port;
		if(map_mapname2ipport(sd->mapindex,&ip,&port)==0)
			chrif_changemapserver(sd, ip, port);
		else //too much lag/timeout is the closest explanation for this error.
			clif_authfail_fd(sd->fd, 3);
		break;
		}
	}
	return 0;
}
示例#2
0
文件: chrif.c 项目: Shaktoh/Hercules
/**
 * This can still happen (client times out while waiting for char to confirm auth data)
 * @see DBApply
 */
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
	struct auth_node *node = DB->data2ptr(data);
	const char* states[] = { "Login", "Logout", "Map change" };
	
	if(DIFF_TICK(gettick(),node->node_created)>60000) {
		switch (node->state) {
			case ST_LOGOUT:
				//Re-save attempt (->sd should never be null here).
				node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
				chrif_save(node->sd, 1);
				break;
			default:
				//Clear data. any connected players should have timed out by now.
				ShowInfo("auth_db: Node (state %s) timed out for %d:%d\n", states[node->state], node->account_id, node->char_id);
				chrif_char_offline_nsd(node->account_id, node->char_id);
				chrif_auth_delete(node->account_id, node->char_id, node->state);
				break;
		}
		return 1;
	}
	return 0;
}
示例#3
0
//This can still happen (client times out while waiting for char to confirm auth data)
int auth_db_cleanup_sub(DBKey key,void *data,va_list ap)
{
	struct auth_node *node=(struct auth_node*)data;
	const char* states[] = { "Iniciar Sessao", "Encerrar Sessao", "Mudanca de Mapa" };
	if(DIFF_TICK(gettick(),node->node_created)>60000) {
		switch (node->state)
		{
		case ST_LOGOUT:
			//Re-save attempt (->sd should never be null here).
			node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
			chrif_save(node->sd, 1);
			break;
		default:
			//Clear data. any connected players should have timed out by now.
			ShowInfo("auth_db: No (estado %s) tempo esgotado para %d:%d\n", states[node->state], node->account_id, node->char_id);
			chrif_char_offline_nsd(node->account_id, node->char_id);
			chrif_auth_delete(node->account_id, node->char_id, node->state);
			break;
		}
		return 1;
	}
	return 0;
}