예제 #1
0
파일: swtrack.cpp 프로젝트: krafczyk/AMS
bool SWTrack::checkButtons(int x, int y)
{
  int fold = focusStatus;
  checkClose(x, y);
  checkMore (x, y);
  if (fold != focusStatus) return true;

  x -= pX;
  y -= pY;

  for (int i = 0; i < NPAR; i++) {
    if (fitPar[i] && i != fID && (drawStatus & (FOCUS_OPT*(1 << i)))) {
      int mx = BFP_X+BFP_W*i;
      int my = tHei-MORE_H-MORE_Y;
      if (mx <= x && x <  mx+BFP_W && 
	  my <= y && y <= my+MORE_H) {
	focusStatus |= FOCUS_OPT;
	focusStatus |= FOCUS_OPT*(i+1)*2;
      }
    }
  }

  for (int i = 0; i < 2; i++) {
    int mx = BLY_X+BLY_W*i;
    int my = tHei-MORE_H-MORE_Y;
    if (mx <= x && x <  mx+BLY_W && my <= y && y <= my+MORE_H) {
      focusStatus |= FOCUS_OPT;
      focusStatus |= FOCUS_OPT*(i+NPAR+1)*2;
    }
  }
  
  return (fold != focusStatus);
}
예제 #2
0
void Astar::starSearch(int fid)
{
    auto item = (AstarItem*)_close->getObjectAtIndex(fid);
    int col = item->getCol();
    int row = item->getRow();

    // 搜索目前的点的上,下,左,右四个方向

    // 下
    int mycol = col;
    int myrow = row - 1;
    if(myrow >= 0 && checkMap(mycol, myrow)) {
        if(checkOpen(mycol, myrow, fid) && checkClose(mycol, myrow)) {
            addToOpen(mycol, myrow, fid);
        }
    }

    // 左
    mycol = col - 1;
    myrow = row;
    if(mycol >= 0 && checkMap(mycol, myrow)) {
        if(checkOpen(mycol, myrow, fid) && checkClose(mycol, myrow)) {
            addToOpen(mycol, myrow, fid);
        }
    }

    // 上
    mycol = col;
    myrow = row + 1;
    if(myrow < _map->getMapSize().height && checkMap(mycol, myrow)) {
        if(checkOpen(mycol, myrow, fid) &&checkClose(myrow, myrow)) {
            addToOpen(mycol, myrow, fid);
        }
    }

    // 右
    mycol = col + 1;
    myrow = row;
    if(mycol < _map->getMapSize().height && checkMap(mycol, myrow)) {
        if(checkOpen(mycol, myrow, fid) &&checkClose(myrow, myrow)) {
            addToOpen(mycol, myrow, fid);
        }
    }

}
예제 #3
0
파일: swladder.cpp 프로젝트: krafczyk/AMS
bool SWLadder::checkFocus(int x, int y)
{
  int fold = focusStatus;

  focusStatus = 0;
  checkClose(x, y);
  checkMore (x, y);

  x -= pX;
  y -= pY;

  int llen = nSen*SEN_DX;
  int px = (wWid-llen)/2;
  int py = (wHei-tHei-AXIS_H-SEN_SY)/2+tHei;

  int fobj = -1, dmin = 0, drng = 5;

  for (int i = 0; i < drawObj.size(); i++) {
    DrawObj dobj = drawObj.at(i);
    drawObj[i].atrb &= ~ATR_SEL;

    int d = -1;
    if (dobj.atrb & ATR_CLSX) {
      if (px+dobj.x-drng <= x && x <= px+dobj.x+drng && 
	  py <= y && y <= py+SEN_SY)
	d = abs(x-px-dobj.x);
    }
    else if (dobj.atrb & ATR_CLSY) {
      if (px <= x && x <= px+nSen*SEN_DX && 
	  py+dobj.y-drng <= y && y <= py+dobj.y+drng)
	d = abs(y-py-dobj.y);
    }
    else if ((dobj.atrb & ATR_HIT) || (dobj.atrb & ATR_TRK)) {
      if (px+dobj.x-drng <= x && x <= px+dobj.x+drng && 
	  py+dobj.y-drng <= y && y <= py+dobj.y+drng)
	d = qMin(abs(x-px-dobj.x), abs(y-py-dobj.y));
    }

    if (d >= 0 && (fobj < 0 || d <= dmin)) {
      fobj = i;
      dmin = d;
    }
  }

  if (fobj >= 0) {
    focusStatus |= FOCUS_DOBJ;
    focusStatus |= FOCUS_DOBJ*(fobj+1)*2;
    drawObj[fobj].atrb |= ATR_SEL;
  }

  return (fold != focusStatus);
}
예제 #4
0
void grille::checkClose(int x, int y)
{
	if(x >= 0 && x < (this->getSizeMap().getX()/10) && y >= 0 && y < (this->getSizeMap().getY()/10) && this->listeCases[x][y] == 0)
	{
        if(!this->is_checkClose) this->is_checkClose = true;
		this->listeCases[x][y] = 2;

        checkClose(x+1, y);
        checkClose(x-1, y);
        checkClose(x, y+1);
        checkClose(x, y-1);
        checkClose(x+1, y+1);
        checkClose(x+1, y-1);
        checkClose(x-1, y+1);
        checkClose(x-1, y-1);
    }

	if(x < (this->getSizeMap().getX()/10) && !this->is_checkClose) checkClose(x+1,y);
}
예제 #5
0
int main(){
  low(26);
  low(27);

  while(1){
    checkClose();
    if (end == 1){
      break;
    }
  }

  print("Rotation:%f Distance:%f\n", degrees, moved);
  return 1;
}
예제 #6
0
void PacketDumper::dumpPacket(const struct pcap_pkthdr *h, const u_char *packet,
                              dump_reason reason, int sampling_rate,
                              unsigned int max_pkts_per_file, unsigned int max_sec_per_file) {

  // ntop->getTrace()->traceEvent(TRACE_WARNING, "%s(len=%u)", __FUNCTION__, h->len);
  if(!dumper) openDump(h->ts.tv_sec, sampling_rate, max_pkts_per_file, max_sec_per_file);

  int rate_dump_ok = reason != ATTACK || num_dumped_packets % sampling_rate == 0;

  if(dumper && rate_dump_ok) {
    pcap_dump((u_char*)dumper, h, packet);
    num_dumped_packets++;
    checkClose(h->ts.tv_sec);
  }
}
예제 #7
0
void dialog_inputs::on_btn_ok_clicked()
{
    writeXml();

    checkClose();
}
예제 #8
0
int main(){
    int rst; // Return status of functions.
    int cfd; // File descriptor for the client.
    /***************DESERIALISE****************/
    //THIS NEEDS TO BE DONE
    /**************** Create a socket. *******************************/
    int sfd; // Socket file descriptor.
    sfd = socket (AF_INET, SOCK_STREAM, 0); /* AF_INET --> IPv4,
                * SOCK_STREAM --> TCP Protocol, 0 --> for the protocol. */
    if (sfd == -1) 
    {
        perror ("Server: socket error");
        exit (1);
    }
    printf ("Socket fd = %d\n", sfd);
    
    
    
    /***************** Assign an address to the server **************/
    struct sockaddr_in srv_addr, cli_addr; // Addresses of the server and the client.
    socklen_t addrlen = sizeof (struct sockaddr_in); // size of the addresses.
    
    // Clear the two addresses.
    memset (&srv_addr, 0, addrlen);
    memset (&cli_addr, 0, addrlen);

    // Assign values to the server address.
    srv_addr.sin_family = AF_INET; // IPv4.
    srv_addr.sin_port   = htons (28962); // Port Number.
    
    rst = inet_pton (AF_INET, "127.0.0.1", &srv_addr.sin_addr); /* To 
                              * type conversion of the pointer here. */
    if (rst <= 0)
    {
        perror ("Server Presentation to network address conversion.\n");
        exit (1);
    }    
    
    
    
    /****************** Bind the server to an address. ***************/
    rst = bind (sfd, (struct sockaddr *) &srv_addr, addrlen); /* Note
        * the type casting of the pointer to the server's address. */
    if (rst == -1)
    {
        perror ("Server: Bind failed");
        exit (1);
    }
    char buf[BUF_SIZE]={'\0'};

    for(int numberOfIterations=0;numberOfIterations<=3;numberOfIterations++){
	    printf("Max connections allowed to wait: %d\n",SOMAXCONN);
	    rst=listen(sfd,6);
	    if(rst==-1){
	        perror("Server: Listen Failed");
	        exit(1);
	    }

	    printf("Waiting___waiting\n");
	    cfd = accept (sfd, (struct sockaddr *) &cli_addr, &addrlen);
	    if(cfd==-1){
	        perror("Server: Accept Failed");
	        exit(1);
	    }
	    pid_t childProcess=fork();
	    if(childProcess==0){
	    	rst=recv(cfd,buf,BUF_SIZE,0);
	    	checkRecieve(rst);
	    	printf("Message from client->%s\n",buf);
	    	std::string message="hello world";
	    	memset(buf,'\0',BUF_SIZE);
	    	strcpy(buf,message.c_str());
	    	rst=send(cfd,buf,BUF_SIZE,0);
	    	return 0;
	    }
    }
    rst=close(sfd);
    checkClose(rst);
}
예제 #9
0
파일: tile.cpp 프로젝트: TripleWhy/Carcasum
void Node::connect(Node * n, Game * g)
{
	Q_ASSERT_X(n->getTerrain() == this->getTerrain(), "Node::connect", "TerrainType does not match");
	Q_ASSERT_X(typeid(*n) == typeid(*this), "Node::connect", "classes do not match");
	Q_ASSERT(getScored() == NotScored);
	Q_ASSERT(n->getScored() == NotScored);
	Q_ASSERT(data.scored == NotScored);
	Q_ASSERT(n->data.scored == NotScored);

#if PRINT_CONNECTIONS
	qDebug() << "  connect:" << n->id() << "->" << id() << "   BEFORE";
//	for (Tile const * t : d->tiles)
//		qDebug() << "    " << id() << t->id;
//	for (Tile const * t : n->d->tiles)
//		qDebug() << "    " << n->id() << t->id;
#endif
	
	if (!isSame(n))
	{
//	for (Node ** & p : n->pointers)
//	{
//		*p = this;
//		pointers.push_back(p);
////		p = 0;
//	}
		d->tiles.insert(n->d->tiles.begin(), n->d->tiles.end());
		for (uchar * tm = d->meeples, * end = d->meeples + (g->getPlayerCount()), * nm = n->d->meeples;
			 tm < end;
			 ++tm, ++nm)
		{
			*tm = (uchar)(*tm + *nm);
			if (*tm > d->maxMeples)
				d->maxMeples = *tm;
		}
		
		d->nodes.insert(n->d->nodes.begin(), n->d->nodes.end());
#if PRINT_CONNECTIONS
//		qDebug() << "  connect:" << n->id() << "->" << id();
#endif
	}
#if PRINT_CONNECTIONS
	else
	{
//		qDebug() << "  connect:" << n->id() << "->" << id() << "skipped";
		qDebug() << "  skpped";
	}
	
//	qDebug() << "  connect:" << n->id() << "->" << id() << "   AFTER";
//	for (Tile const * t : d->tiles)
//		qDebug() << "    " << id() << t->id;
//	for (Tile const * t : n->d->tiles)
//		qDebug() << "    " << n->id() << t->id;
#endif
	
//	Q_ASSERT(n->d == &n->data);
	for (Node * o : d->nodes)
	{
		if (o == this)
			continue;
		o->ds.push_back(d);
		o->d = d;
	}

	if (isOccupied())
		checkClose(g);
}
예제 #10
0
void PacketDumper::idle(time_t when) {
  checkClose(when);
}
예제 #11
0
void dialog_delftParams::on_btn_ok_clicked()
{
    writeXml();

    checkClose();
}