Beispiel #1
0
void* sender_capfile(struct thread_data* td, void* ptr){
	send_proc_t* proc = (send_proc_t*)ptr;

	logmsg(stderr, SENDER, "Initializing (local mode).\n");

	struct destination dst;
	destination_init(&dst, 0);
	dst.want_ethhead = 0;
	dst.want_sendhead = 0;

	//if ( (ret=createstream(&con.stream, &dest, NULL, mampid_get(MPinfo->id), MPinfo->comment)) != 0 ){
	//  logmsg(stderr, SENDER, "  createstream() returned 0x%08lx: %s\n", ret, caputils_error_string(ret));
	//      sem_post(proc->semaphore); /* unlock main thread */
	//  return NULL;
	//}

	/* unlock main thread */
	thread_init_finished(td, 0);

	while( terminateThreads == 0 ){
		int oldest = oldest_packet(proc->nics, proc->semaphore);

		/* couldn't find a packet, gave up waiting. we are probably terminating. */
		if ( oldest == -1 ){
			continue;
		}

		struct CI* CI = &_CI[oldest];
		struct write_header* whead = CI_packet(CI, CI->readpos);

		copy_to_sendbuffer(&dst, whead, CI);
		send_packet(&dst);
	}

	destination_free(&dst);

	logmsg(stderr, SENDER, "Finished (local).\n");
	return NULL;
}
Beispiel #2
0
void destination_init_all(size_t requested_buffer_size){
	for( int i = 0; i < MAX_FILTERS; i++) {
		destination_init(&MAsd[i], i, requested_buffer_size);
	}
}
Beispiel #3
0
	void Bullet::destination_init() {

		int delta_x = utilities::random_integer(0, this->game_state->get_width() * delta_x_max),
			delta_y = utilities::random_integer(this->game_state->get_height() * delta_y_min, this->game_state->get_height() * delta_y_max);

		delta_x = (delta_x % 2 == 0) ? (delta_x) : (delta_x * -1); // this is the random error entered into the element!

		int _x = this->initial.x() + delta_x,//x can move left or right of the element
			_y = this->initial.y() - delta_y;//y should always be moving upwards on the screen
 
		// validate the new position to ensure that it is in the screen -- assume the size is relevant as well
		if (_x < 0 || (_x + this->geometry().width()) > this->game_state->get_width()) return destination_init();

		if (_y < 0 || (_y + this->geometry().height()) > this->game_state->get_height()) return destination_init();

		// set the destination elements 
		this->destination = QPoint(_x, _y);//create a position for the destination -- can be used for rotation later

	}