Пример #1
0
void interactRays(thrust::host_vector<Ray> &h_rays) {
	int n = h_rays.size();
	for (int i = 0; i < n; i++) {
		Ray &r = h_rays[i];
		interact(r);
	}
}
Пример #2
0
void ProcessRunner::run()
{
  if (!process)
    process = new QProcess();
#ifdef WIN32
  QProcessEnvironment env = env.systemEnvironment();
  env.insert("CYGWIN", "nodosfilewarning");
  process->setProcessEnvironment(env);
#endif

  connect(process, SIGNAL(readyReadStandardError()), this, SLOT(updateError()), Qt::DirectConnection);
  connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()), Qt::DirectConnection);

  if(arguments)
    process->start(program, *arguments);
  else
    process->start(program);

  interact(process);
  process->waitForFinished(-1); // no timeout

  process->close();

  disconnect(process, SIGNAL(readyReadStandardError()), this, SLOT(updateError()));
  disconnect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()));
}
Пример #3
0
void playSongs(char nots[100]){
    int i = 0;
    while(i < 100 && strcmp(&nots[i], "\0")){
        interact(nots[i]);
        i++;
    }
}
Пример #4
0
int
main() {
  int retval;
  char cont;

  struct stack *stack;
  stack = stack_new(STACK_SIZE);

  cont = 1;
  while(cont) {
    retval = interact(stack);
    switch (retval) {
    case EXIT_OP:
      cont = 0;
      break;
    case INVALID_CHAR:
      printf("Invalid char!\n");
      break;
    case STACK_UNDERFLOW:
      printf("Stack underflow!\n");
      break;
    case STACK_OVERFLOW:
      printf("Stack overflow!\n");
      break;
    default:
      continue;
    }
  }

  stack_free(stack);

  return 0;
}
Пример #5
0
static void real_start(void *param) {
	dbgio_printk_func old;
	
	/* Set debug output to the serial console again */
	old = dbgio_set_printk(dbgio_write_str);

	/* Make a semaphore */
	/* chr_ready = sem_create(0); */

	/* Hook the serial IRQ */
	/* irq_set_handler(EXC_SCIF_RXI, ser_irq);
	*SCSCR2 |= 1 << 6;
	*iprc |= 0x000e << 4; */

	/* Do the shell */
	interact();
	dbgio_write_str("shell exiting\n");

	/* Unhook serial IRQ */
	/* *iprc &= ~(0x000e << 4);
	*SCSCR2 &= ~(1 << 6);
	irq_set_handler(EXC_SCIF_RXI, NULL); */

	/* Destroy the semaphore */
	/* sem_destroy(chr_ready); */

	dbgio_set_printk(old);
}
Пример #6
0
int main(int argc, char *argv[])
{
  greet();
  interact();
  /* When interact returns, session is done. */
  printf("Bye!\n");
  return 0;
}
Пример #7
0
bool process_input(){
    
    key = getKeyB();
    
    
    
    if(key == -1 || key == 44){
        quit = 1;
    }
    
    
    if(RIGHT && maze[py][px+1] != B){
        
        move_player(py, px+1);
        interact();
        
    }
    
    
    if(LEFT &&  maze[py][px-1]!= B ){
        
        move_player(py, px-1);
        interact();
    }
    
    
    if(UP && maze[py+1][px] != B){
        
        move_player(py+1, px);
        interact();
    }
    
    
    if(DOWN && maze[py-1][px] != B){
        
        move_player(py-1, px);
        interact();
        
        
    }
    
    
    
    return true;
    
}
Пример #8
0
SchObj sch_read ( FILE* fp )
{
    if ( fp ) {
        return 0;
    } else {
        return interact();
    }
}
Пример #9
0
// Function for computing interaction between two sets of particles
void compute_self_interaction(struct Particle *set, int size){
  int j,k;
  
  for(j = 0; j < size; j++){
    for(k = j+1; k < size; k++){
      interact(&set[j],&set[k]);
    }
  }
}
Пример #10
0
// Function for computing interaction between two sets of particles
void compute_interaction(struct Particle *first, struct Particle *second, int limit){
  int j,k;
  
  for(j = 0; j < limit; j++){
    for(k = 0; k < limit; k++){
      interact(&first[j],&second[k]);
    }
  }
}
Пример #11
0
int main(int argc, char **argv) {
	char *host;
	if(argc > 1)
		host = argv[1];
	else
		host = "localhost";
	interact(connect_to_server(host));   
	return 0;
}
Пример #12
0
// -----------------------------------------------------------------
// Name : checkInteractions
// -----------------------------------------------------------------
void AI::checkInteractions()
{
	list<PartitionableItem*> lstSurrounding;
	getSurroundingObjects(&lstSurrounding, isSurrounding);

	for (PartitionableItem * pItem : lstSurrounding) {
		interact((GameObject*) pItem);
	}
}
Пример #13
0
static void
run_scripts(struct bu_list *sl, struct rt_i *rtip)
{
    struct script_rec *srp;
    char *cp;
    FILE *fPtr;

    if (nirt_debug & DEBUG_SCRIPTS)
	show_scripts(sl, "before running them");

    while (BU_LIST_WHILE(srp, script_rec, sl)) {
	BU_LIST_DEQUEUE(&(srp->l));
	BU_CKMAG(srp, SCRIPT_REC_MAGIC, "script record");
	cp = bu_vls_addr(&(srp->sr_script));

	if (nirt_debug & DEBUG_SCRIPTS) {
	    bu_log("  Attempting to run %s '%s'\n",
		   (srp->sr_type == READING_STRING) ? "literal" :
		   (srp->sr_type == READING_FILE) ? "file" : "???",
		   cp);
	}

	switch (srp->sr_type) {
	    case READING_STRING:
		interact(READING_STRING, cp, rtip);
		break;
	    case READING_FILE:
		if ((fPtr = fopen(cp, "rb")) == NULL) {
		    bu_log("Cannot open script file '%s'\n", cp);
		} else {
		    interact(READING_FILE, fPtr, rtip);
		    fclose(fPtr);
		}
		break;
	    default:
		bu_exit (1, "%s:%d: script of type %d.  This shouldn't happen\n", __FILE__, __LINE__, srp->sr_type);
	}
	free_script(srp);
    }

    if (nirt_debug & DEBUG_SCRIPTS)
	show_scripts(sl, "after running them");
}
Пример #14
0
//
// move() - Hit a monster, or move to a square
//
// We calculate the coordinates we are trying to move to, then check if there is
// a monster there. If there is, we hit it. Otherwise, we interact with the tile
//
bool player::move( command d )
{
	int newx, newy;
	switch( d )
	{
		case NORTH:
			newx = x;
			newy = y - 1;
			break;
		case SOUTH:
			newx = x;
			newy = y + 1;
			break;
		case EAST:	
			newx = x + 1;
			newy = y;
			break;
		case WEST:
			newx = x - 1;
			newy = y;
			break;
		case NW:
			newx = x - 1;
			newy = y - 1;
			break;
		case NE:
			newx = x + 1;
			newy = y - 1;
			break;
		case SW:
			newx = x - 1;
			newy = y + 1;
			break;
		case SE:
			newx = x + 1;
			newy = y + 1;
			break;
		// This isn't a direction!
		default:
			return false;
	}
	entity* monster = get_entity_at( newx, newy );
	if( monster != NULL )
	{
		monster->hurt( damage );
		return true;
	}
	else
	{
		bool done;
		done = interact( newx, newy, this );
		return done;
	}
}
Пример #15
0
void AGOSEngine_PN::opn_opcode37() {
	_curwrdptr = NULL;

	_inputReady = true;
	interact(_inputline, 49);

	if ((_inpp = strchr(_inputline,'\n')) != NULL)
		*_inpp = '\0';
	_inpp = _inputline;
	setScriptReturn(true);
}
Пример #16
0
 Piece &Agent::operator*(Piece &other) {
     Piece *p = &other;
     Resource *res = dynamic_cast<Resource*>(p);
     if (res) {
         interact(res);
     }
     Agent *agent = dynamic_cast<Agent*>(p);
     if (agent) {
         interact(agent);
     }
     if (!isFinished()) {
         //survivor
         Position pNew;
         pNew = other.getPosition();
         Position pOld;
         pOld = getPosition();
         setPosition(pNew);
         other.setPosition(pOld);
     }
     return *this;
 }
Пример #17
0
static void run_calibration()
{
    float roll_trim, pitch_trim;
    // clear off any other characters (like line feeds,etc)
    while( hal.console->available() ) {
        hal.console->read();
    }


    AP_InertialSensor_UserInteractStream interact(hal.console);
    ins.calibrate_accel(&interact, roll_trim, pitch_trim);
}
Пример #18
0
int
main(int argc, char *argv[], char *envv[], struct bootinfo *bootinfop)
{
	struct devsw **dp;

	/* NB: Must be sure to bzero() before using any globals. */
	bzero(&__bss_start, (uintptr_t)&__bss_end - (uintptr_t)&__bss_start);

	boot2_argc = argc;
	boot2_argv = argv;
	boot2_envv = envv;
	boot2_bootinfo = *bootinfop;	/* Copy rather than by reference. */

	setheap((void *)&__heap_start, (void *)&__heap_end);

	/*
	 * Pick up console settings from boot2; probe console.
	 */
	if (bootinfop->bi_boot2opts & RB_MULTIPLE) {
		if (bootinfop->bi_boot2opts & RB_SERIAL)
			setenv("console", "comconsole vidconsole", 1);
		else
			setenv("console", "vidconsole comconsole", 1);
	} else if (bootinfop->bi_boot2opts & RB_SERIAL)
		setenv("console", "comconsole", 1);
	else if (bootinfop->bi_boot2opts & RB_MUTE)
		setenv("console", "nullconsole", 1);
	cons_probe();
	setenv("LINES", "24", 1);

	printf("%s(%d, %p, %p, %p (%p))\n", __func__, argc, argv, envv,
	    bootinfop, (void *)bootinfop->bi_memsize);

	/*
	 * Initialise devices.
	 */
	for (dp = devsw; *dp != NULL; dp++) {
		if ((*dp)->dv_init != NULL)
			(*dp)->dv_init();
	}
	extract_currdev(bootinfop);

	printf("\n");
	printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
	printf("(%s, %s)\n", bootprog_maker, bootprog_date);
#if 0
	printf("bootpath=\"%s\"\n", bootpath);
#endif

	interact(NULL);
	return (0);
}
void back::interactcheck(gamelevel* level)
{
    bool inmenu;
    string iminput;
    int tick = 0;
    do
    {
        cout<<"#"<<endl;
        cout<<"# with:"<<endl;
        getline(cin,iminput);

        searcher = current->childone;
        if(searcher->menuname == iminput)
        {
            interact(searcher);
        }
        else if(searcher->menuname != iminput)
        {
            while(searcher->menuname != iminput)
            {
                searcher = searcher->next;
                tick++;
                if(tick > 10)
                {
                    cout<<"# wrong input"<<endl;
                    EImenu(level);
                }
            }
            interact(searcher);
        }
        else
        {
            cout<<"# wrong input"<<endl;
            inmenu = true;
        }
    }
    while(inmenu == true);
}
Пример #20
0
void
load_state(char *UNUSED(buffer), com_table *UNUSED(ctp), struct rt_i *rtip)
{
    FILE *sfPtr;

    if ((sfPtr = fopen(sf_name, "rb")) == NULL) {
	fprintf(stderr, "Cannot open statefile '%s'\n", sf_name);
	return;
    }
    bu_log("Loading NIRT state from file '%s'...", sf_name);
    interact(READING_FILE, sfPtr, rtip);
    bu_log("\n");
    fclose(sfPtr);
}
int main(int argc, char* argv[]) {
    
    int sockfd = init_socket();
    logf("Server listening on port %d\n", PORT);
  
    if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
        perror("Error setting SIGCHILD handler.");
        return EXIT_FAILURE;
    }

    load_module();

    while (1) {
        socklen_t client_len = sizeof(client);
        int client_fd = accept(sockfd, (struct sockaddr*) &client, &client_len);
        if (client_fd < 0) {
            perror("Error creating socket for incoming connection");
            exit(EXIT_FAILURE);
        }
        logf("New connection from %s on port %d\n", inet_ntoa(client.sin_addr), htons(client.sin_port));

        int pid = fork();
        if (pid < 0) {
            perror("Unable to fork");
            exit(EXIT_FAILURE);
        }

        if (pid == 0) { // client
            alarm(300);
            close(sockfd);

            dup2(client_fd, 0);
            dup2(client_fd, 1);
            setvbuf(stdout, NULL, _IONBF, 0);

            drop_privs();

            interact();

            close(client_fd);
            logf("%s:%d disconnected\n", inet_ntoa(client.sin_addr), htons(client.sin_port));
            exit(EXIT_SUCCESS);
        } else {        // server
            logf("%s:%d forked new process with pid %d\n", inet_ntoa(client.sin_addr), htons(client.sin_port), pid);
            close(client_fd);
        }

    }
}
Пример #22
0
void attack() {
  // Select a hard-coded guess ...
  char* G = "guess";

  int   t;
  int   r;

  // ... then interact with the attack target.
  interact( &t, &r, G );

  // Print all of the inputs and outputs.
  printf( "G = %s\n", G );
  printf( "t = %d\n", t );
  printf( "r = %d\n", r );
}
Пример #23
0
int main(int argc, char *argv[])
{
	//QAppliction app(argc, argv);
	//Qtdemo *w = new Qtdemo;
    usb_dev_handle *dev=NULL;
    float fit[10];
	init(dev,fit);//show();
    interact(dev);
    //if (argc>1) save(argv[1],0);
    //else save("data1.txt",0);
    usb_close(dev);
    //w->on_CloseCommBtn_clicked();
	//app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
	return 1;//app.exec();
}
Пример #24
0
void BedTest2(){
    std::cout<<"ROOM AND COMFORTABLE BED 2\n"<<std::endl;
    Infector::Container ioc;

    ioc.bindSingleAs<ComfortableBedVS,  IBedVS>();
    ioc.bindSingleAs<BedRoomVS,         IRoomVS>();

    ioc.wire<ComfortableBedVS>();
    ioc.wire<BedRoomVS,           IBedVS>();

    auto room = ioc.buildSingle<IRoomVS>();
    room->interact();

    assert("test 8 failed" && CCallBedVS==1);
    assert("test 8 failed" && CCallRoomVS==1);

    std::cout<<"\nend of test 8\n"<<std::endl;
}
Пример #25
0
void CmdManager::run(int argc, char** argv)
{
	bool isint = argc <= 1;
	
	for(int i = 1; i<argc; ++i)
	{ 
		std::string a = getargv(i, argc, argv);
		
		if(a == "-i")
			isint = true;
		else if(a == "-e")
			execfile(getargv(++i, argc, argv));
		else if(a == "-p")
			execute(getargv(++i, argc, argv));
	}
	
	interact();
}
Пример #26
0
void BedTest(){
    std::cout<<"ROOM AND COMFORTABLE BED\n"<<std::endl;
    Infector::Container ioc;

    ioc.bindAs<ComfortableBed,  IBed>();
    ioc.bindAs<BedRoom,         IRoom>();

    ioc.wire<ComfortableBed>();
    ioc.wire<BedRoom,           IBed>();

    auto room = ioc.build<IRoom>();
    room->interact();

    assert("test 2 failed" && CCallBed==1);
    assert("test 2 failed" && CCallRoom==1);

    std::cout<<"\nend of test 2\n"<<std::endl;
}
Пример #27
0
    bool myBox::collidesZ( myBox b, int speed ){
        
        
        if(minz - speed < b.getMaxZ() && maxz - speed > b.getMinZ() ){

            if(minx < b.getMaxX() && maxx > b.getMinX() ){
                
                if(miny > b.getMaxY() && maxy < b.getMinY()){
                
                    interact();
                    return true;
                    
                }
            }
            
        }
        
        return false;
    }
void GameObjectManager::handleInteractions()
{
  // Default interaction handler:  Check all movable objects against all objects
  for(ObjectSetIter mit = m_movableObjects.begin(); mit != m_movableObjects.end(); ++mit)
  {
    if((*mit)->m_lifeState != GameObject::LS_ALIVE)
      continue;
    for(ObjectSetIter oit = m_objects.begin(); oit != m_objects.end(); ++oit)
      {
        // Handling duplicate interactions (i.e., preventing interact(o1,o2)
        // and interact(o2,o1)):  Duplicates only occur between any pair of
        // movable objects o1 and o2.  (Think about it.) Therefore, if both
        // objects are movable, only call once.  A simple ID ordering
        // accomplishes our objective.
        if((*oit)->m_lifeState != GameObject::LS_ALIVE)
          continue;
        if((*mit)->m_id != (*oit)->m_id && ((*mit)->m_id < (*oit)->m_id || m_movableObjects.find(*oit) == m_movableObjects.end()))
          interact(**mit, **oit);
      }
  }
}
// uppdaterar alla objekt
void EntityManager::update()
{
	if(mPlayerLife > 0)
	{
		for(EntityVector::size_type i = 0; i < mCharacters.size(); ++i)
		{
			//if(!mCantMoveCharacters)
			//{
				mCharacters[i]->update(mPrimaryCharacter);
			//}
			//else
			//{
			//	Entity::EntityKind noCharacter = Entity::DOOR;
			//	mCharacters[i]->update(noCharacter);	
			//}
		}

		for(EntityVector::size_type i = 0; i < mEntities.size(); ++i)
		{
			if(mEntities[i]->getBaseKind() != Entity::CHARACTER)
			{
				mEntities[i]->update(mPrimaryCharacter);
			}
		}	

		updatePlayerLife();
		interact();
		killEntity();

		updatePlayerLife();
		lifeAndMaskPosition();

		updatePlayerPortrait();
		updateBackgroundParalax();
	}
	
	killPlayers();

	
}
Пример #30
0
int main(int argc, char **argv) {
	// Lot of arg parsing here

	clean_exedir();

	parse_opts(argc, argv);

	struct sigaction sa = {};

	REQUIRE (sigemptyset(&sa.sa_mask) == 0);
	sa.sa_sigaction = sigchld_handler;
	sa.sa_flags     = SA_NOCLDSTOP | SA_SIGINFO;

	REQUIRE (sigaction(SIGCHLD, &sa, NULL) == 0);

	if (isatty(STDIN_FILENO))
		interact(argv[0]);
	else
		pipe_mode();

	return 0;
}