Example #1
0
	void tick(const float dt) {
		const std::string &state = get_state();
		if (_velocity.is0() && state == "move") {
			cancel_all();
			play("hold", true);
		} else if (!_velocity.is0() && state == "hold") {
			cancel_all();
			play("move", true);
		}
		RotatingObject::tick(dt);
	}
Example #2
0
void Launcher::tick(const float dt) {
	Object::tick(dt);
	if (!playing_sound("vehicle-sound")) {
		play_sound("vehicle-sound", true, 0.4f);
	}

	bool fire_possible = _fire.tick(dt);
	
	if (get_state().empty()) {
		play("hold", true);
		group_emit("mod", "hold");
	}

	if (_velocity.is0()) {	
		cancel_repeatable();
		play("hold", true);
		group_emit("mod", "hold");
	} else {
		if (get_state() == "hold") {
			cancel_all();
			//play("start", false);
			play("move", true);
			group_emit("mod", "move");
		}
	}

	if (_state.fire && fire_possible) {
		_fire.reset();
		group_emit("mod", "launch");
	}
	if (_state.alt_fire && fire_possible) {
		_fire.reset();
		group_emit("alt-mod", "launch");
	}
}
Example #3
0
void Submarine::tick(const float dt) {
	Object::tick(dt);

	if (!playing_sound("submarine")) {
		play_sound("submarine", true);
	}

	if (get_state().empty()) {
		_wakeup.set(mrt::random(5) + 5);
		play("hold", true);
	}
	if (_wakeup.tick(dt)) {
		//LOG_DEBUG(("waking up..."));
		spawnBallistic();
		_wakeup.set(3600);
		
		cancel_all();
		play("fade-in", false);
		int n = mrt::random(3) + 3;
		for(int i = 0; i < n; ++i) {
			play("main", false);
		}

		play("fade-out", false);
	}
}
Example #4
0
int
main(int argc, char **argv) {
	isc_result_t result;

	interactive = ISC_TF(isatty(0));

	ISC_LIST_INIT(lookup_list);
	ISC_LIST_INIT(server_list);
	ISC_LIST_INIT(search_list);

	check_ra = ISC_TRUE;

	result = isc_app_start();
	check_result(result, "isc_app_start");

	setup_libs();
	progname = argv[0];

	setup_system();
	parse_args(argc, argv);
	if (keyfile[0] != 0)
		setup_file_key();
	else if (keysecret[0] != 0)
		setup_text_key();
	if (domainopt[0] != '\0')
		set_search_domain(domainopt);
	if (in_use)
		result = isc_app_onrun(mctx, global_task, onrun_callback,
				       NULL);
	else
		result = isc_app_onrun(mctx, global_task, getinput, NULL);
	check_result(result, "isc_app_onrun");
	in_use = ISC_TF(!in_use);

	(void)isc_app_run();

	puts("");
	debug("done, and starting to shut down");
	if (global_event != NULL)
		isc_event_free(&global_event);
	cancel_all();
	destroy_libs();
	isc_app_finish();

	return (query_error | print_error);
}
Example #5
0
void Cannon::tick(const float dt) {
	Object::tick(dt);
	if (get_state() == "real-fire") {
		cancel();
		spawn("cannon-bullet", "cannon-bullet", v2<float>(), _direction);
	}
	
	bool can_fire = _fire.tick(dt);
	if (_state.fire && can_fire) {
		_fire.reset();
		
		if (get_state() == "hold") {
			cancel_all();
			play("fire", false);
			play("real-fire", true);
			play("after-fire", false);
			play("hold", true);
		}
	}
}
Example #6
0
File: dig.c Project: Gradwell/bind9
/*% Main processing routine for dig */
int
main(int argc, char **argv) {
	isc_result_t result;

	ISC_LIST_INIT(lookup_list);
	ISC_LIST_INIT(server_list);
	ISC_LIST_INIT(search_list);

	debug("main()");
	preparse_args(argc, argv);
	progname = argv[0];
	result = isc_app_start();
	check_result(result, "isc_app_start");
	setup_libs();
	parse_args(ISC_FALSE, ISC_FALSE, argc, argv);
	setup_system();
	if (domainopt[0] != '\0') {
		set_search_domain(domainopt);
		usesearch = ISC_TRUE;
	}
	result = isc_app_onrun(mctx, global_task, onrun_callback, NULL);
	check_result(result, "isc_app_onrun");
	isc_app_run();
	destroy_lookup(default_lookup);
	if (batchname != NULL) {
		if (batchfp != stdin)
			fclose(batchfp);
		batchname = NULL;
	}
#ifdef DIG_SIGCHASE
	clean_trustedkey();
#endif
	cancel_all();
	destroy_libs();
	isc_app_finish();
	return (exitcode);
}
Example #7
0
int main(int argc, char *argv[]){
//	struct dns	dns[5];
	unsigned int /*miner_id,*/ i;//, num_nodes;
	struct threads *threads=NULL; 
//	mcheck(NULL);

	dead = NULL;
	global_id = 0;
// random seed
	srand(time(NULL));

//nodes list initialization
	threads = NULL;

//DNS nodes initialization 
	memset(&dns, 0, NUM_DNS*sizeof(struct dns)); //will delete?

//Seeds Initialization
//	fprintf(stderr, "seeds' subnet\n");
	int subnet = rand() & 0xffff0000;
 	for(i=0; i<SEED_NUM; i++){
		if(i>=SEED_NUM/2 && i < SEED_NUM/2 +1)
			subnet = rand() & 0xffff0000;
		seeds[i] = malloc(sizeof(struct miner));
		memset(seeds[i], 0, sizeof(struct miner));
		memset(&seeds[i]->addrman, 0, sizeof(struct addrman));
		seeds[i]->seed		= true;
		seeds[i]->TTL		= SIM_TIME;
		seeds[i]->miner_id	= global_id;
		global_id++;
		seeds[i]->subnet		= subnet;
//		fprintf(stderr, "seeds[i]->subnet: %d\n", seeds[i]->subnet);
	}

//bad nodes/DNS initialization
	for(i=0; i<NUM_DNS; i++){
		is_bad_dns[i] = false;
	}
	bad_links = NULL;
#ifdef	MULTI
	pthread_mutex_init(&block_mutex, NULL);
#endif	//MULTI

#ifdef BAD_NODES
	unsigned int num_nodes;
#ifdef MULTI
	struct threads *bad_threads;
#endif //MULTI

	for(num_nodes=0; num_nodes<BAD_NODES; global_id++){
#ifdef MULTI
		bad_threads=new_thread(ATTACKER, global_id, bad_threads, 0);
#endif	//MULTI
#ifndef	MULTI
		threads=new_thread(ATTACKER, global_id, threads, 0);
/*		if(bad_threads==NULL){
			bad_threads=malloc(sizeof(struct bad_threads));
			bad_threads->thread=threads;
			bad_threads->next=NULL;
			bad_threads->prev=NULL;
		}
		else{
			struct bad_threads bad_threads_tmp;
			for(bad_threads_tmp=bad_threads;bad_threads_tmp->next!=NULL;bad_threads_tmp=bad_threads_tmp->next){}
			bad_threads_tmp->next=malloc(sizeof(struct bad_threads));
			bad_threads_tmp->next->thread=threads;
			bad_threads_tmp->next->prev=bad_threads_tmp;
			
		}
*/
#endif	//MULTI
		num_nodes++;
	}
#endif //BAD_NODES

/////////////////////////////////////////////////////////////////////
// the main routine	
/////////////////////////////////////////////////////////////////////
// sim_time=1 : 1 second
	for(sim_time = 0; sim_time < SIM_TIME; sim_time++){
#ifdef DEBUG
		fprintf(stderr, "sim_time = %d\n", sim_time);//debug
#endif

#ifdef	DEBUG
		struct killed *killed;
		fprintf(stderr, "dead nodes: ");
		for(killed = dead; killed!=NULL; killed = killed->next){
			fprintf(stderr, "id= %d, ", killed->id);
		}
		fprintf(stderr, "\n");
#endif	//DEBUG
#ifdef	DEBUG
		struct links *links;
		if(bad_links!=NULL){
			fprintf(stderr, "bad_links: ");
			for(links=bad_links; links->prev!=NULL; links=links->prev){}
			for(; links!=NULL; links = links->next){
				fprintf(stderr, "id= %d, ", links->miner_id);
			}
			fprintf(stderr, "\n");
		}
#endif	//DEBUG
// kill/create nodes, manage total hash-rate
		threads = cancel_by_TTL(threads);
//		threads = keep_total_seeds(threads);
		threads = keep_total_nodes(threads);
		if(sim_time==0)
			make_random_connection(threads);
		keep_total_hash_rate_1(threads);
		if(sim_time%600==0){
//			fprintf(stderr, "in bad_links: ");
			
			add_link_records(threads);
#ifdef	MULTI
			add_link_records(bad_threads);
#endif	//MULTI
			print_link_record();
			fprintf(stderr, "SIM_TIME: %d, sim_time: %d\n", SIM_TIME, sim_time);
		}

// routine
#ifdef	MULTI
		pthread_t t1, t2, t3, t4;
		struct thread_arg thread_arg[4];
		int	j;
		for(;threads->next!=NULL; threads=threads->next){}
		for(i=1; threads->prev!=NULL; threads=threads->prev){ i++;}
		thread_arg[0].num 		= i/4;
		thread_arg[0].thread	= threads;
		pthread_create(&t1, NULL, (void * (*)(void *))thread_job, &thread_arg[0]);
		for(j=0; j<=i/4&& threads->next!=NULL; threads=threads->next){ j++;}
		thread_arg[1].num		= i/4;
		thread_arg[1].thread	= threads;
		pthread_create(&t2, NULL, (void * (*)(void *))thread_job, &thread_arg[1]);
		for(j=0; j<=i/4&& threads->next!=NULL; threads=threads->next){ j++;}
		thread_arg[2].num		= i/4;
		thread_arg[2].thread	= threads;
		pthread_create(&t3, NULL, (void * (*)(void *))thread_job, &thread_arg[2]);
		for(j=0; j<=i/4&& threads->next!=NULL; threads=threads->next){ j++;}
		thread_arg[3].num		= 0;
		thread_arg[3].thread	= threads;
		pthread_create(&t4, NULL, (void * (*)(void *))thread_job, &thread_arg[3]);
		pthread_join(t1, NULL);
		pthread_join(t2, NULL);
		pthread_join(t3, NULL);
		pthread_join(t4, NULL);
		for(; threads->prev!=NULL; threads=threads->prev){}
		for(; threads->next!=NULL; threads=threads->next){
			threads->done = false;
		}
		threads->done=false;
#endif
#ifndef	MULTI
		for(;threads->next!=NULL; threads=threads->next){}
		for(;;threads=threads->prev){
#ifdef	DEBUG
		fprintf(stderr, "threads->miner->miner_id= %d\n", threads->miner->miner_id);
#endif	//DEBUG
			if(threads->miner->seed == true){
#ifdef	DEBUG
				fprintf(stderr, "\nminer: %d seed: %d\n", (threads->miner)->miner_id, threads->miner->seed);
				fprintf(stderr, "created at: %d\n", threads->time);
#endif	//DEBUG
					miner_routine(threads->miner);

			}
			else{
				if(threads->type==ATTACKER){
#ifdef	BAD_NODES
					bad_miner_routine(threads->miner);
#endif	//BAD_NODES
				}
				else{
//					if(sim_time>=SIM_TIME-1){
#ifdef	DEBUG
					fprintf(stderr, "\nminer: %d seed: %d\n", (threads->miner)->miner_id, threads->miner->seed);
					fprintf(stderr, "created at: %d\n", threads->time);
#endif	//DEBUG
//					}
					miner_routine(threads->miner);
				}
			}
			if(threads->prev==NULL)
				break;
		}
#endif	//MULTI
		for(i=0; i<SEED_NUM; i++){
#ifdef DEBUG
			fprintf(stderr, "\nminer: %d seed: %d\n", seeds[i]->miner_id, seeds[i]->seed);
#endif

			miner_routine(seeds[i]);
		}
#ifdef	MULTI
#ifdef	DEBUG
		fprintf(stderr, "bad_threads = %p\n", bad_threads);
#endif	//DEBUG
		for(; bad_threads->next!=NULL; bad_threads=bad_threads->next){
#ifdef	DEBUG
			fprintf(stderr, "bad_threads = %p, bad_threads->next = %p\n", bad_threads, bad_threads->next);
#endif	//DEBUG
			if(bad_threads->next==NULL)
				break;
		}
#ifdef	BAD_NODES
		for(i=0; i<BAD_NODES; i++){
				bad_miner_routine(bad_threads->miner);
				if(bad_threads->prev==NULL)
					break;
				bad_threads=bad_threads->prev;
		}
#endif	//BAD_NODES
#endif	//MULTI
		for(i=0; i<NUM_DNS; i++){
#ifdef DEBUG
			fprintf(stderr, "dns[%d]\n", i);
#endif
			dns_routine(&dns[i], i);
		}
	}
#ifdef DEBUG
	fprintf(stderr, "will cancel_all()\n"); //debug
#endif
	cancel_all(threads);
	cancel_seeds();
	free_killed();
//	free_bad_links();
	print_link_record();
	print_block_record();
	exit(1);
}