void ChannelH11::timerEvent(QTimerEvent *event){
    //meshplot(10);

    char buff[14404*3+10];

    recvfrom(sockser_chl1,&buff,14404*3+10,0,(struct sockaddr *)&addrrcv_chl1,(socklen_t*)&size_chl1);
    qDebug() << "Counter is " << cnt++ << endl;
    // inverse
    for( int i = 0 ; i < 7203 ; i ++){
       int position = i * 6;
       char tmp;
       //swap
       tmp = buff[position];
       buff[position] = buff[position+3];
       buff[position+3] = tmp;
       //swap
       position ++;
       tmp = buff[position];
       buff[position] = buff[position+3];
       buff[position+3] = tmp;
    }//for
   // qDebug() << buff << endl;

    rendermap(buff);
    updateGL();
    //qDebug()<< "timer event in mygl2 Class!" << endl;
}
char multiloop(GameStruct* game)
{
	PlayerStruct players[2];
	MainStruct mains;
	ItemStruct zombie[MAX_ZOMBIES];
	ItemStruct shots[2][2];

	init(&mains, players, 2, game, zombie, shots);

	for(;;game->frames++)
	{
		WaitVsync(1);

		multidrawoverlay(game, players);
		gameflags(game);

		for(int p = 0; p < 2; p++)
		{
			playerflags(&players[p]);
			players[p].joypad = ReadJoypad(p);
		}

		if(players[0].life <= 0 && players[1].life <= 0)
		{
			switch(gameovermenu(game, &players[0]))
			{
				case 1:
					return 2;
				case 2:
					return 0;
				default:
					break;
			}
		}
		else if((players[0].joypad&BTN_SELECT || players[1].joypad&BTN_SELECT) && game->flagcount >= DEBOUNCE_DELAY)
		{
			game->flagcount = 0;
			if(game->flags & GAMEPAUSED)
				game->flags &= ~GAMEPAUSED;
			else
				game->flags |= GAMEPAUSED;
		}
	
		if(game->flags & GAMEPAUSED)
			continue;

		rendermap(&mains, 2);
		screenSections[1].scrollX = mains.x.s;
		screenSections[1].scrollY = mains.y.s;

		if(players[0].life > 0 && players[1].life > 0)
			multimove(players, &mains, shots);
		else if(players[0].life <= 0)
			singlemove(&(players[1]), &mains, shots[1]);
		else if(players[1].life <= 0)
			singlemove(&(players[0]), &mains, shots[0]);

		necromancer(zombie, &mains, game, players, 2);

		for(int p = 0; p < 2; p++)
		{
			inputanim(&(players[p]));
			players[p].gundelay++; 
			for(int i = 0; i < 2; i++)
				handleshot(&mains, game, &players[p], &shots[p][i], zombie);

			if(!(players[p].flags & PLAYERHURT) || game->frames&2)
			{
				sprites[1 + p * 4].x = sprites[2  + p * 4].x = players[p].x;
				sprites[1  + p * 4].y = players[p].y;
				sprites[2  + p * 4].y = players[p].y + TILE_HEIGHT;
			}
			else
			{
				sprites[1  + p * 4].x = sprites[2  + p * 4].x = DISABLED_SPRITE;
				sprites[2  + p * 4].y = sprites[1  + p * 4].y = DISABLED_SPRITE;
			}
		}


	
	}
}
char singleloop(GameStruct* game)
{
	PlayerStruct singlep;
	MainStruct mains;
	ItemStruct zombie[MAX_ZOMBIES];
	ItemStruct shots[2];

	init(&mains, &singlep, 1, game, zombie, shots);

	for(;; game->frames++)
	{
		WaitVsync(1);

		drawoverlay(game, &singlep);
		gameflags(game);
		playerflags(&singlep);

		singlep.joypad = ReadJoypad(0);

		if(singlep.life <= 0)
		{
			switch(gameovermenu(game, &singlep))
			{
				case 1:
					return 1;
				case 2:
					return 0;
				default:
					break;
			}
		}
		else if(singlep.joypad&BTN_SELECT && game->flagcount >= DEBOUNCE_DELAY)
		{
			game->flagcount = 0;
			if(game->flags & GAMEPAUSED)
				game->flags &= ~GAMEPAUSED;
			else
				game->flags |= GAMEPAUSED;
		}
	
		if(game->flags & GAMEPAUSED)
			continue;
		
		rendermap(&mains, 1);

		screenSections[1].scrollX = mains.x.s;	
		screenSections[1].scrollY = mains.y.s;

		singlemove(&singlep, &mains, shots);
		inputanim(&singlep);

		singlep.gundelay++;
		for(int i = 0; i < 2; i++)
			handleshot(&mains, game, &singlep, &shots[i], zombie);
 
		
		necromancer(zombie, &mains, game, &singlep, 1);

		if(!(singlep.flags & PLAYERHURT) || game->frames&2)
		{
			sprites[1].x = sprites[2].x = singlep.x;
			sprites[1].y = singlep.y;
			sprites[2].y = singlep.y + TILE_HEIGHT;
		}
		else
		{
			sprites[1].x = sprites[2].x = DISABLED_SPRITE;
			sprites[2].y = sprites[1].y = DISABLED_SPRITE;
		}

	}

}